toggleGutterIcon()

in src/common/quick_chat/quick_chat_gutter_icon.ts [21:46]


  toggleGutterIcon(thread: vscode.CommentThread | null) {
    const threadUri = thread?.uri;
    const editor = vscode.window.activeTextEditor;
    const isInLogOutput = editor?.document.languageId === 'Log';

    const isInCommentInput = editor?.document.uri.authority === COMMENT_CONTROLLER_ID;
    const isCollapsed = thread?.collapsibleState === vscode.CommentThreadCollapsibleState.Collapsed;

    // If we're in comment input or output panel, find the editor for the thread's document
    const targetEditor =
      isInCommentInput || isInLogOutput
        ? vscode.window.visibleTextEditors.find(e => e.document.uri === threadUri)
        : editor;

    this.resetGutterIcon(targetEditor);

    const shouldShowIcon = targetEditor && !isCollapsed && targetEditor.document.uri === threadUri;

    if (!shouldShowIcon || !thread) return;

    targetEditor.setDecorations(this.#gutterIconDecoration, [
      {
        range: new vscode.Range(thread.range.end, thread.range.end),
      },
    ]);
  }