Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

antimonyGu
Copy link
Contributor

@antimonyGu antimonyGu commented Dec 31, 2024

@icycodes
Copy link
Member

icycodes commented Jan 2, 2025

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.

@antimonyGu antimonyGu changed the title feat(vscode): add shortcur hint in codeLens title feat(vscode): add shortcut hint in codeLens title Jan 2, 2025
@antimonyGu antimonyGu force-pushed the add-shortcur-for-accept branch from 73a5a83 to bb0aedd Compare January 2, 2025 22:01
Copy link
Member

@icycodes icycodes left a 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.

Comment on lines +78 to +86

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);
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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"})`;
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants