mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Prioritize “property names” over punctuation in smart select (#32687)
* Prioritize “property names” over punctuation in smart select * Update doc comment
This commit is contained in:
parent
e75972cbad
commit
725321f08c
@ -17,7 +17,7 @@ namespace ts.SmartSelectionRange {
|
||||
break outer;
|
||||
}
|
||||
|
||||
if (positionShouldSnapToNode(pos, node, nextNode)) {
|
||||
if (positionShouldSnapToNode(sourceFile, pos, node)) {
|
||||
// 1. Blocks are effectively redundant with SyntaxLists.
|
||||
// 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
|
||||
// of things that should be considered independently.
|
||||
@ -97,12 +97,11 @@ namespace ts.SmartSelectionRange {
|
||||
* count too, unless that position belongs to the next node. In effect, makes
|
||||
* selections able to snap to preceding tokens when the cursor is on the tail
|
||||
* end of them with only whitespace ahead.
|
||||
* @param sourceFile The source file containing the nodes.
|
||||
* @param pos The position to check.
|
||||
* @param node The candidate node to snap to.
|
||||
* @param nextNode The next sibling node in the tree.
|
||||
* @param sourceFile The source file containing the nodes.
|
||||
*/
|
||||
function positionShouldSnapToNode(pos: number, node: Node, nextNode: Node | undefined) {
|
||||
function positionShouldSnapToNode(sourceFile: SourceFile, pos: number, node: Node) {
|
||||
// Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts
|
||||
// for missing nodes, which can’t really be considered when deciding what
|
||||
// to select.
|
||||
@ -111,9 +110,8 @@ namespace ts.SmartSelectionRange {
|
||||
return true;
|
||||
}
|
||||
const nodeEnd = node.getEnd();
|
||||
const nextNodeStart = nextNode && nextNode.getStart();
|
||||
if (nodeEnd === pos) {
|
||||
return pos !== nextNodeStart;
|
||||
return getTouchingPropertyName(sourceFile, pos).pos < node.end;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -44,7 +44,10 @@ class HomePage {
|
||||
}
|
||||
|
||||
|
||||
)
|
||||
username
|
||||
|
||||
|
||||
this.props.username
|
||||
|
||||
|
||||
if (this.props.username) {
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
console/**/.log();
|
||||
|
||||
console
|
||||
console.log
|
||||
console.log()
|
||||
console.log();
|
||||
@ -0,0 +1,5 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////console/**/.log();
|
||||
|
||||
verify.baselineSmartSelection();
|
||||
Loading…
x
Reference in New Issue
Block a user