Skip to content

Commit

Permalink
Merge branch 'main' of github.com:getcursor/cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
truell20 committed Mar 27, 2023
2 parents 65d45c9 + b44e640 commit aaab4b8
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 7 deletions.
Binary file modified assets/icon/icon.icns
Binary file not shown.
Binary file modified assets/icon/icon.ico
Binary file not shown.
Binary file modified assets/icon/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icon/icon128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icon/icon16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icon/icon32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icon/icon64.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"uuid": "^9.0.0",
"watcher": "^2.2.2",
"webpack": "^5.75.0",
"xterm": "^4.19.0"
"xterm": "^4.19.0",
"xterm-addon-web-links": "^0.6.0"
}
}
3 changes: 1 addition & 2 deletions src/appComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Modal from 'react-modal'

import { useAppSelector, useAppDispatch } from './app/hooks'
import { PaneHolder } from './components/pane'
import { LeftSide } from './components/search'
import * as gs from './features/globalSlice'
import * as cs from './features/chat/chatSlice'
import * as ct from './features/chat/chatThunks'
Expand All @@ -31,7 +30,7 @@ import _ from 'lodash'

import { ChatPopup, CommandBar } from './components/markdown'
import { SettingsPopup } from './components/settingsPane'
import { FeedbackArea } from './components/search'
import { FeedbackArea, LeftSide } from './components/search'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { WelcomeScreen } from './components/welcomeScreen'
import { TitleBar } from './components/titlebar'
Expand Down
14 changes: 14 additions & 0 deletions src/components/terminal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useRef } from 'react'
import { Terminal } from 'xterm'
import { FitAddon } from 'xterm-addon-fit'
import { WebLinksAddon } from 'xterm-addon-web-links';
import 'xterm/css/xterm.css'
import { useAppSelector, useAppDispatch } from '../app/hooks'
import { FullState } from '../features/window/state'
Expand All @@ -13,6 +14,12 @@ export function XTermComponent({ height }: { height: number }) {
const terminalRef = useRef<HTMLDivElement>(null)
const terminal = useRef<Terminal | null>(null)
const fitAddon = useRef<FitAddon>(new FitAddon())
const webLinksAddon = useRef<WebLinksAddon>(new WebLinksAddon(
(event: MouseEvent, url: string) => {
event.preventDefault()
connector.terminalClickLink(url)
},
))

const handleIncomingData = (e: any, data: any) => {
terminal.current!.write(data)
Expand All @@ -30,6 +37,7 @@ export function XTermComponent({ height }: { height: number }) {
})

terminal.current.loadAddon(fitAddon.current)
terminal.current.loadAddon(webLinksAddon.current)

if (terminalRef.current) {
terminal.current.open(terminalRef.current)
Expand All @@ -41,6 +49,11 @@ export function XTermComponent({ height }: { height: number }) {
connector.terminalInto(e)
})

terminal.current.onData((e) => {
connector.terminalInto(e)
})


connector.registerIncData(handleIncomingData)

// Make the terminal's size and geometry fit the size of #terminal-container
Expand All @@ -55,6 +68,7 @@ export function XTermComponent({ height }: { height: number }) {
useEffect(() => {
if (terminal.current != null) {
terminal.current.loadAddon(fitAddon.current)
terminal.current.loadAddon(webLinksAddon.current)
fitAddon.current.fit()
}
}, [height, terminal, fitAddon])
Expand Down
2 changes: 1 addition & 1 deletion src/features/chat/chatSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const chatSlice = createSlice({
useDiagnostics?: boolean | number
}>
) {
chatState.chatIsOpen = true
// chatState.chatIsOpen = true

const lastUserMessage = chatState.userMessages.at(-1)!
const type = action.payload.type
Expand Down
5 changes: 5 additions & 0 deletions src/main/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import log from 'electron-log'
import Store from 'electron-store'
import fixPath from 'fix-path'
import { fileSystem } from './fileSystem'

const writeFilePromise = promisify(fs.writeFile)
const lspDir = app.isPackaged
Expand Down Expand Up @@ -360,6 +361,10 @@ class LSPManager {
case 'go':
const goDir = path.join(lspDir, 'go')
try {
// Check $GOPATH, and remove $GOPATH/go.mod file
const goPath = cp.execSync('echo $GOPATH').toString().trim()
fs.accessSync(`${goPath}go.mod`, fs.constants.F_OK)
await fileSystem.unlinkSync(`${goPath}/go.mod`)
await promisify(cp.exec)(
'go install golang.org/x/tools/gopls@latest',
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,12 @@ const createWindow = () => {
}
return null
})

// click on the terminal link
ipcMain.handle('terminal-click-link', (event, data) => {
shell.openExternal(data);
})

setupLSPs(store)
const projectPathObj = store.get('projectPath')
if (
Expand Down
1 change: 1 addition & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const electronConnector = {
ipcRenderer.removeListener('terminal-incData', callback)
},
terminalInto: (data: any) => ipcRenderer.invoke('terminal-into', data),
terminalClickLink: (data: any) => ipcRenderer.invoke('terminal-click-link', data),
terminalResize: (data: any) => ipcRenderer.invoke('terminal-resize', data),

registerFileWasAdded: (callback: Callback) =>
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const API_ROOT = 'https://aicursor.com'

export class NoAuthRateLimitError extends Error {
constructor(
message: string = 'You have reached the rate limit for unauthenticated requests. Please authenticate to continue.'
message = 'You have reached the rate limit for unauthenticated requests. Please authenticate to continue.'
) {
super(message)
this.name = 'NoAuthRateLimitError'
Expand All @@ -11,7 +11,7 @@ export class NoAuthRateLimitError extends Error {

export class AuthRateLimitError extends Error {
constructor(
message: string = 'You have reached the rate limit for authenticated requests. Please wait before making more requests.'
message = 'You have reached the rate limit for authenticated requests. Please wait before making more requests.'
) {
super(message)
this.name = 'AuthRateLimitError'
Expand Down

0 comments on commit aaab4b8

Please sign in to comment.