Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Dec 24, 2024
1 parent eb74dc0 commit 92be7b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clients/tabby-chat-panel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export interface FileLocation {
* The location in the file.
* It could be a 1-based line number, a line range, a position or a position range.
*/
location: Location
location?: Location
}

/**
Expand Down
2 changes: 1 addition & 1 deletion clients/vscode/src/chat/WebviewHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ export class WebviewHelper {
}
}

const targetRange = chatPanelLocationToVSCodeRange(fileLocation.location) ?? new Range(0, 0, 0, 0);
const targetRange = fileLocation.location ? chatPanelLocationToVSCodeRange(fileLocation.location) ?? new Range(0, 0, 0, 0) : new Range(0, 0, 0, 0);
try {
await commands.executeCommand(
"editor.action.goToLocations",
Expand Down
6 changes: 5 additions & 1 deletion ee/tabby-ui/lib/types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { ArrayElementType } from './common'
export interface FileContext {
kind: 'file'
filepath: string
range: { start: number; end: number }
/**
* The range of the selected content in the file.
* If the range is not provided, the whole file is considered.
*/
range?: { start: number; end: number }
content: string
git_url: string
}
Expand Down
8 changes: 4 additions & 4 deletions ee/tabby-ui/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ export function formatLineHashForLocation(location: Location | undefined) {
const start = location.start
if (typeof start === 'number') {
const end = location.end as number
return `L${start}-${end}`
return `L${start}-L${end}`
}
if (
typeof start === 'object' &&
'line' in start &&
typeof start.line === 'number'
) {
const end = location.end as Position
return `L${start.line}-${end.line}`
return `L${start.line}-L${end.line}`
}
}
return ''
Expand Down Expand Up @@ -199,9 +199,9 @@ export function convertEditorContext(
editorContext: EditorContext
): FileContext {
const convertRange = (range: LineRange | PositionRange | undefined) => {
// FIXME: If the range is not provided, the whole file is considered.
// If the range is not provided, the whole file is considered.
if (!range) {
return { start: 0, end: 0 }
return undefined
}

if (typeof range.start === 'number') {
Expand Down

0 comments on commit 92be7b5

Please sign in to comment.