Simplify same line logic in find token
This commit is contained in:
committed by
Christopher Schleiden
parent
634cac8eb4
commit
b4f6e674b7
@@ -54,9 +54,8 @@ export function findToken(pos: Position, root?: TemplateToken): TokenResult {
|
||||
for (let i = 0; i < mappingToken.count; i++) {
|
||||
const {key, value} = mappingToken.get(i);
|
||||
|
||||
const sameLine = onSameLine(pos, key, value);
|
||||
if (posInToken(pos, key)) {
|
||||
if (sameLine && key.range!.end[1] + 1 === value.range!.start[1]) {
|
||||
if (onSameLine(pos, key, value)) {
|
||||
if (posInToken(pos, key) && key.range!.end[1] + 1 === value.range!.start[1]) {
|
||||
// There's no space between the key and value, there's nothing valid to complete here
|
||||
return {
|
||||
token: null,
|
||||
@@ -65,20 +64,14 @@ export function findToken(pos: Position, root?: TemplateToken): TokenResult {
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
token: key,
|
||||
keyToken: null,
|
||||
parent: mappingToken
|
||||
};
|
||||
}
|
||||
|
||||
// Empty nodes positions won't always match the cursor, so check if we're on the same line
|
||||
if (sameLine && emptyNode(value)) {
|
||||
return {
|
||||
token: value,
|
||||
keyToken: null,
|
||||
parent: key
|
||||
};
|
||||
// Empty nodes positions won't always match the cursor, so check if we're on the same line
|
||||
if (emptyNode(value)) {
|
||||
return {
|
||||
token: value,
|
||||
keyToken: null,
|
||||
parent: key
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
s.push({
|
||||
|
||||
Reference in New Issue
Block a user