Set completion range for invalid token
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user