Skip to content

Commit

Permalink
fix out of range errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Feb 28, 2024
1 parent 0546c77 commit 14f68d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/extension/providers/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ export class CompletionProvider implements InlineCompletionItemProvider {
const fileChunks: string[] = []
for (const interaction of interactions) {
const filePath = interaction.name

if (filePath.toString().match('.git')) {
continue
}

const uri = Uri.file(filePath)

if (currentFileName === filePath) continue
Expand All @@ -260,8 +265,8 @@ export class CompletionProvider implements InlineCompletionItemProvider {
const averageLine =
activeLines.reduce((acc, curr) => acc + curr.line, 0) /
activeLines.length
const start = new Position(Math.ceil(averageLine) - 100, 0)
const end = new Position(Math.ceil(averageLine) + 100, 0)
const start = new Position(Math.max(0, Math.ceil(averageLine) - 100), 0)
const end = new Position(Math.min(lineCount, Math.ceil(averageLine) + 100), 0)
fileChunks.push(`
// File: ${filePath}
// Content: \n ${document.getText(new Range(start, end))}
Expand Down

0 comments on commit 14f68d6

Please sign in to comment.