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 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
[autofix.ci] apply automated fixes
  • Loading branch information
autofix-ci[bot] authored and antimonyGu committed Jan 7, 2025
commit 5d384d24ba04fbdeb15890a90a8f54650c5f810e
17 changes: 8 additions & 9 deletions clients/vscode/src/lsp/CodeLensMiddleware.ts
Original file line number Diff line number Diff line change
@@ -81,10 +81,9 @@ export class CodeLensMiddleware implements VscodeLspCodeLensMiddleware {
}

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);
this.purgeDecorationMap();
return result;
}
@@ -113,16 +112,16 @@ export class CodeLensMiddleware implements VscodeLspCodeLensMiddleware {
return null;
}

private addShortcut(codeLens: CodeLens) {
private addShortcut(codeLens: CodeLens) {
if (codeLens.command?.arguments?.[0].action === "accept") {
// TODO: read keybinds from LSP client, then send to LSP server to avoid hardcode.
const acceptShortcut = isBrowser ? '' : ` (${process.platform === 'darwin' ? 'cmd+enter' : 'ctrl+enter'})`;
const acceptShortcut = isBrowser ? "" : ` (${process.platform === "darwin" ? "cmd+enter" : "ctrl+enter"})`;
antimonyGu marked this conversation as resolved.
Show resolved Hide resolved

codeLens.command.title += (acceptShortcut);
codeLens.command.title += acceptShortcut;
} else if (codeLens.command?.arguments?.[0].action === "discard") {
const discardShortcut = isBrowser ? '' : ` (esc)`;
const discardShortcut = isBrowser ? "" : ` (esc)`;
antimonyGu marked this conversation as resolved.
Show resolved Hide resolved

codeLens.command.title += (discardShortcut);
codeLens.command.title += discardShortcut;
}
}