Set completion range for invalid token

This commit is contained in:
Jacob Wallraff
2023-01-12 15:17:46 -08:00
parent dd386b06bb
commit 51908ec789
2 changed files with 38 additions and 0 deletions
+7
View File
@@ -103,6 +103,13 @@ export async function complete(
if (token?.range) {
replaceRange = mapRange(token.range);
}
else if (!token) {
// Not a valid token, create a range from the current position
const line = newDoc.getText({start: {line: position.line, character: 0}, end: position});
// Get the length of the current word
const val = line.match(/[\w_-]*$/)?.[0].length || 0;
replaceRange = Range.create({ line: position.line, character: position.character - val } as Position, position);
}
return values.map(value => {
const newText = value.insertText || value.label;