Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r--editors/code/src/commands.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 64af124e72..a78696e186 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -31,6 +31,7 @@ import type { LanguageClient } from "vscode-languageclient/node";
import { HOVER_REFERENCE_COMMAND } from "./client";
import type { DependencyId } from "./dependencies_provider";
import { log } from "./util";
+import type { SyntaxElement } from "./syntax_tree_provider";
export * from "./ast_inspector";
export * from "./run";
@@ -357,6 +358,38 @@ export async function execRevealDependency(e: RustEditor): Promise<void> {
await vscode.commands.executeCommand("rust-analyzer.revealDependency", e);
}
+export function syntaxTreeReveal(): Cmd {
+ return async (element: SyntaxElement) => {
+ const activeEditor = vscode.window.activeTextEditor;
+
+ if (activeEditor !== undefined) {
+ const start = activeEditor.document.positionAt(element.start);
+ const end = activeEditor.document.positionAt(element.end);
+
+ const newSelection = new vscode.Selection(start, end);
+
+ activeEditor.selection = newSelection;
+ activeEditor.revealRange(newSelection);
+ }
+ };
+}
+
+export function syntaxTreeHideWhitespace(ctx: CtxInit): Cmd {
+ return async () => {
+ if (ctx.syntaxTreeProvider !== undefined) {
+ await ctx.syntaxTreeProvider.toggleWhitespace();
+ }
+ };
+}
+
+export function syntaxTreeShowWhitespace(ctx: CtxInit): Cmd {
+ return async () => {
+ if (ctx.syntaxTreeProvider !== undefined) {
+ await ctx.syntaxTreeProvider.toggleWhitespace();
+ }
+ };
+}
+
export function ssr(ctx: CtxInit): Cmd {
return async () => {
const editor = vscode.window.activeTextEditor;