Skip to content

Commit f3612b7

Browse files
committed
vscode: scroll to the syntax node in rust editor when highlighting
1 parent e86bfc0 commit f3612b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

editors/code/src/commands/syntax_tree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class AstInspector implements vscode.HoverProvider, Disposable {
127127
if (!rustTextRange) return;
128128

129129
this.rustEditor.setDecorations(AstInspector.astDecorationType, [rustTextRange]);
130+
this.rustEditor.revealRange(rustTextRange);
130131

131132
const rustSourceCode = this.rustEditor.document.getText(rustTextRange);
132133
const astTextRange = this.findAstRange(astTextLine);
@@ -145,7 +146,7 @@ class AstInspector implements vscode.HoverProvider, Disposable {
145146
const parsedRange = /\[(\d+); (\d+)\)/.exec(astLine);
146147
if (!parsedRange) return;
147148

148-
const [, begin, end] = parsedRange.map(off => doc.positionAt(+off));
149+
const [begin, end] = parsedRange.slice(1).map(off => doc.positionAt(+off));
149150

150151
return new vscode.Range(begin, end);
151152
}

0 commit comments

Comments
 (0)