diff --git a/package-lock.json b/package-lock.json index a6aacfe8..16bd7fe3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "twinny", - "version": "3.7.9", + "version": "3.7.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "twinny", - "version": "3.7.9", + "version": "3.7.10", "license": "MIT", "dependencies": { "@types/react": "^18.2.46", diff --git a/package.json b/package.json index 383f0245..a9c5ae64 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/extension/utils.ts b/src/extension/utils.ts index 38d4946d..869f84d2 100644 --- a/src/extension/utils.ts +++ b/src/extension/utils.ts @@ -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