Use parent token (revertable)

This commit is contained in:
Jacob Wallraff
2023-01-17 10:27:51 -08:00
parent d7761dc538
commit d5831b2e89
+2 -6
View File
@@ -102,12 +102,8 @@ export async function complete(
let replaceRange: Range | undefined;
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}, position);
} else if (!token && parent?.range) {
replaceRange = mapRange(parent.range)
}
return values.map(value => {