Repository: TabbyML/tabby
File: clients/vscode/src/lsp/CodeLensMiddleware.ts (TypeScript)

Code before:
      return codeLens;
    }
    return null;
  }

  private addDecorationRange(editor: TextEditor, decorationType: TextEditorDecorationType, range: Range) {
    let decorations: Map<TextEditorDecorationType, Range[]> | undefined;
    if (this.decorationMap.has(editor)) {
      decorations = this.decorationMap.get(editor);
    }
    if (!decorations) {
      decorations = new Map();
      this.decorationMap.set(editor, decorations);
    }
    let ranges: Range[] | undefined;
    if (decorations.has(decorationType)) {
      ranges = decorations.get(decorationType);
    }
    if (!ranges) {
      ranges = [];
      decorations.set(decorationType, ranges);
    }
    ranges.push(range);
    editor.setDecorations(decorationType, ranges);
  }
  private addShortcut(codeLens: CodeLens) {
    const action = codeLens.command?.arguments?.[0]?.action;
    if (!action) return;

    let commandId: string;
    if (action === "accept") {
      commandId = "tabby.chat.edit.accept";
    } else if (action === "discard") {
      commandId = "tabby.chat.edit.discard";
    } else {
      return;
    }
    const binding =
      VSCodeKeyBindingManager.getInstance().getCommandBinding(commandId) || getPackageCommandBinding(commandId);

    const formattedShortcut = binding ? formatShortcut(binding) : "";
    const shortcutText = isBrowser ? "" : formattedShortcut ? ` (${formattedShortcut})` : "";

    if (!codeLens.command) return;

    codeLens.command.title += shortcutText;
  }

  private removeDecorations(editor: TextEditor) {
    if (this.decorationMap.has(editor)) {
      const decorations = this.decorationMap.get(editor);

Review comment (suggestion):
```suggestion
  private appendShortcutHint(codeLens: CodeLens) {
```

Code after:
      return codeLens;
    }
    return null;
  }

  private addDecorationRange(editor: TextEditor, decorationType: TextEditorDecorationType, range: Range) {
    let decorations: Map<TextEditorDecorationType, Range[]> | undefined;
    if (this.decorationMap.has(editor)) {
      decorations = this.decorationMap.get(editor);
    }
    if (!decorations) {
      decorations = new Map();
      this.decorationMap.set(editor, decorations);
    }
    let ranges: Range[] | undefined;
    if (decorations.has(decorationType)) {
      ranges = decorations.get(decorationType);
    }
    if (!ranges) {
      ranges = [];
      decorations.set(decorationType, ranges);
    }
    ranges.push(range);
    editor.setDecorations(decorationType, ranges);
  }
  private appendShortcutHint(codeLens: CodeLens) {
    if (!codeLens.command) return;

    const action = codeLens.command?.arguments?.[0]?.action;
    if (!action) return;

    let commandId: string;
    if (action === "accept") {
      commandId = "tabby.chat.edit.accept";
    } else if (action === "discard") {
      commandId = "tabby.chat.edit.discard";
    } else {
      return;
    }
    const binding = KeyBindingManager.getInstance().getKeybinding(commandId);

    const formattedShortcut = binding ? formatShortcut(binding) : "";
    const shortcutText = isBrowser ? "" : formattedShortcut ? ` (${formattedShortcut})` : "";

    codeLens.command.title += shortcutText;
  }

  private removeDecorations(editor: TextEditor) {
    if (this.decorationMap.has(editor)) {
      const decorations = this.decorationMap.get(editor);
      decorations?.forEach((_, decorationType) => {