-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vscode): add shortcut hint in codeLens title #3637
base: main
Are you sure you want to change the base?
Conversation
antimonyGu
commented
Dec 31, 2024
•
edited
Loading
edited
- Recording: https://jam.dev/c/97d046de-ee6f-42b5-8bef-06dfbbd934d0.
- To do: Read keybinds from LSP client.
Please consider implementing this in the VSCode scope first. This will avoid adding an API to the Tabby-agent protocol. You can try adding the processing in CodeLensMiddleware.ts to modify the CodeLens title. |
73a5a83
to
bb0aedd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase on the main
branch and revert any unrelated changes.
|
||
if (!codeLenses) { | ||
return []; | ||
} | ||
|
||
this.removeDecorations(editor); | ||
const result = | ||
codeLenses | ||
?.map((codeLens) => this.handleCodeLens(codeLens, editor)) | ||
.filter((codeLens): codeLens is CodeLens => codeLens !== null) ?? []; | ||
const result = codeLenses | ||
.map((codeLens) => this.handleCodeLens(codeLens, editor)) | ||
.filter((codeLens): codeLens is CodeLens => codeLens !== null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change necessary? This change will prevent this.removeDecorations(editor)
from being invoked when codelenses
is empty.
@@ -106,6 +112,19 @@ export class CodeLensMiddleware implements VscodeLspCodeLensMiddleware { | |||
return null; | |||
} | |||
|
|||
private addShortcut(codeLens: CodeLens) { | |||
if (codeLens.command?.arguments?.[0].action === "accept") { | |||
// TODO: read ~/.config/Code/User/keybindings.json from LSP client, then send to LSP server to avoid hardcode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: read ~/.config/Code/User/keybindings.json from LSP client, then send to LSP server to avoid hardcode. | |
// FIXME: Read the user keybinding config to check if there is a customized keybinding. |
private addShortcut(codeLens: CodeLens) { | ||
if (codeLens.command?.arguments?.[0].action === "accept") { | ||
// TODO: read ~/.config/Code/User/keybindings.json from LSP client, then send to LSP server to avoid hardcode. | ||
const acceptShortcut = isBrowser ? "" : ` (${process.platform === "darwin" ? "cmd+enter" : "ctrl+enter"})`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the keybinding hint label consistent with VSCode's style.
- On Linux/Windows,
Ctrl+Enter
should be capitalized. - On macOS, Unicode symbols like
⌘
should be used.
Please refer to the VSCode source for more details.