updateThreadSelection()

in src/common/quick_chat/comment_thread_service.ts [108:133]


  updateThreadSelection(documentUri: vscode.Uri, editor: vscode.TextEditor) {
    if (!this.#thread) return;

    const { scheme, authority } = documentUri;

    const isInCommentInput = scheme === 'comment' && authority === COMMENT_CONTROLLER_ID;

    // we do not want to recalculate the label because when the focus moves to the input
    // the editor selection becomes empty and it is reflected on the label
    if (isInCommentInput) return;

    if (editor) {
      const { selection } = editor;

      const range = new vscode.Range(selection.start, selection.end);

      const newText = generateThreadLabel(range);

      if (this.#thread.label !== newText) {
        log.debug(
          `[QuickChat] Selection changed, updating quick chat label: ${newText}, ${this.#thread.label}`,
        );
        this.#thread.label = newText;
      }
    }
  }