Skip to content

Commit

Permalink
Merge pull request #162 from rjmacarthy/development
Browse files Browse the repository at this point in the history
development > main
  • Loading branch information
rjmacarthy committed Mar 4, 2024
2 parents 7bf3858 + 4693136 commit 0e56487
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "twinny",
"displayName": "twinny - AI Code Completion and Chat",
"description": "Locally hosted AI code completion plugin for vscode",
"version": "3.7.9",
"version": "3.7.10",
"icon": "assets/icon.png",
"keywords": [
"code-inference",
Expand Down
8 changes: 6 additions & 2 deletions src/extension/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ export const getPrefixSuffix = (
numLines: number,
document: TextDocument,
position: Position,
contextRatio = [0.15, 0.85]
contextRatio = [0.85, 0.15]
): PrefixSuffix => {
const currentLine = position.line
const numLinesToEnd = document.lineCount - currentLine

let numLinesPrefix = Math.floor(Math.abs(numLines * contextRatio[0]))
let numLinesSuffix = Math.ceil(Math.abs(numLines * contextRatio[1]))

if (numLinesPrefix > currentLine) {
numLinesSuffix += numLinesPrefix - currentLine
numLinesPrefix = currentLine
}

if (numLinesSuffix > numLinesToEnd) {
numLinesPrefix += numLinesSuffix - numLinesToEnd
numLinesSuffix = numLinesToEnd
Expand Down

0 comments on commit 0e56487

Please sign in to comment.