Skip to content

Commit

Permalink
feat(chat): add vscodeRangeToChatPanelLineRange utility function for …
Browse files Browse the repository at this point in the history
…range conversion
  • Loading branch information
Sma1lboy committed Jan 29, 2025
1 parent 70a1955 commit 31c6e39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions clients/vscode/src/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ export function chatPanelLineRangeToVSCodeRange(lineRange: LineRange): VSCodeRan
return new VSCodeRange(Math.max(0, lineRange.start - 1), 0, lineRange.end, 0);
}

export function vscodeRangeToChatPanelLineRange(range: VSCodeRange): LineRange {
return {
start: range.start.line + 1,
end: range.end.line + 1,
};
}

export function chatPanelLocationToVSCodeRange(location: Location | undefined): VSCodeRange | null {
if (!location) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion clients/vscode/src/chat/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
isValidForSyncActiveEditorSelection,
localUriToListFileItem,
escapeGlobPattern,
vscodeRangeToChatPanelLineRange,
} from "./utils";
import { findFiles } from "../findFiles";
import mainHtml from "./html/main.html";
Expand Down Expand Up @@ -607,7 +608,7 @@ export class ChatWebview {
const filepath = localUriToChatPanelFilepath(editor.document.uri, this.gitProvider);
return collectFunctions(symbols || []).map((symbol) => ({
filepath,
range: { start: symbol.location.range.start.line + 1, end: symbol.location.range.end.line + 1 },
range: vscodeRangeToChatPanelLineRange(symbol.location.range),
label: symbol.name,
}));
} catch (error) {
Expand Down

0 comments on commit 31c6e39

Please sign in to comment.