未验证 提交 2558a72d 编写于 作者: P Peng Lyu 提交者: GitHub

Merge pull request #58989 from sbatten/fix/40658

prioritize tokens over brackets in find
......@@ -122,4 +122,44 @@ suite('TokenSelectionSupport', () => {
new Range(3, 1, 3, 2)
]);
});
test('getRangesToPosition #40658. Cursor at first position inside brackets should select line inside.', () => {
assertGetRangesToPosition([
' [ ]',
' { } ',
'( ) '
], 2, 3, [
new Range(1, 1, 3, 5),
new Range(2, 1, 2, 6),
new Range(2, 2, 2, 5),
new Range(2, 3, 2, 4)
]);
});
test('getRangesToPosition #40658. Cursor in empty brackets should reveal brackets first.', () => {
assertGetRangesToPosition([
' [] ',
' { } ',
' ( ) '
], 1, 3, [
new Range(1, 1, 3, 7),
new Range(1, 1, 1, 5),
new Range(1, 2, 1, 4)
]);
});
test('getRangesToPosition #40658. Tokens before bracket will be revealed first.', () => {
assertGetRangesToPosition([
' [] ',
' { } ',
'selectthis( ) '
], 3, 11, [
new Range(1, 1, 3, 15),
new Range(3, 1, 3, 15),
new Range(3, 1, 3, 11)
]);
});
});
......@@ -428,7 +428,7 @@ export function find(node: Node, position: Position): Node {
}
} else if (node instanceof Block) {
result = find(node.open, position) || find(node.elements, position) || find(node.close, position);
result = find(node.elements, position) || find(node.open, position) || find(node.close, position);
}
return result || node;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册