@@ -9,9 +9,10 @@ import {
99 generateDiagramWebviewContent ,
1010 getOrCreateAshStudioWebview ,
1111} from "./features/ashStudioWebview" ;
12- import { CodeLensEntry } from "./types/parser" ;
1312import { getTheoreticalDiagramFilePath } from "./utils/diagramUtils" ;
1413import { generateDiagramWithMix } from "./utils/diagramMixUtils" ;
14+ import { DiagramCodeLensEntry } from "./types/parser" ;
15+ import { GotoFileLocationEntry } from "./types/commands" ;
1516
1617// Debounce map for text change events to prevent excessive parsing
1718const debounceTimers = new Map < string , NodeJS . Timeout > ( ) ;
@@ -105,22 +106,6 @@ export function activate(context: vscode.ExtensionContext) {
105106 registerAshSectionNavigation ( context , parserService ) ;
106107 registerAshCodeLensProvider ( context , parserService ) ;
107108
108- // Register the reveal command that the sidebar uses
109- context . subscriptions . push (
110- vscode . commands . registerCommand (
111- "ash-studio.revealSectionOrSubBlock" ,
112- ( line : number ) => {
113- const editor = vscode . window . activeTextEditor ;
114- if ( editor && typeof line === "number" ) {
115- const position = new vscode . Position ( line , 0 ) ;
116- editor . selection = new vscode . Selection ( position , position ) ;
117- editor . revealRange ( new vscode . Range ( position , position ) ) ;
118- vscode . window . showTextDocument ( editor . document ) ;
119- }
120- }
121- )
122- ) ;
123-
124109 // Register diagram commands
125110 context . subscriptions . push (
126111 vscode . commands . registerCommand (
@@ -133,7 +118,7 @@ export function activate(context: vscode.ExtensionContext) {
133118 * @param entry - The CodeLensEntry containing diagram metadata and resource info
134119 */
135120 "ash-studio.showDiagram" ,
136- async ( filePath : string , entry : CodeLensEntry ) => {
121+ async ( filePath : string , entry : DiagramCodeLensEntry ) => {
137122 const diagramFilePath = getTheoreticalDiagramFilePath (
138123 entry . target ,
139124 entry . diagramSpec
@@ -168,6 +153,33 @@ export function activate(context: vscode.ExtensionContext) {
168153 )
169154 ) ;
170155
156+ // Register generic file location navigation command
157+ context . subscriptions . push (
158+ vscode . commands . registerCommand (
159+ /**
160+ * Registers the ash-studio.gotoFileLocation command to reveal a file and line in the editor.
161+ * Used by all navigation features (code lenses, QuickPick, sidebar, etc.) for unified navigation.
162+ *
163+ * @param filePath - The file path to open
164+ * @param entry - An object containing targetLine or line (1-based)
165+ */
166+ "ash-studio.gotoFileLocation" ,
167+ async ( filePath : string , entry : GotoFileLocationEntry ) => {
168+ const doc = await vscode . workspace . openTextDocument ( filePath ) ;
169+ const editor = await vscode . window . showTextDocument ( doc , {
170+ preview : false ,
171+ } ) ;
172+ const line = Math . max ( 0 , ( entry . targetLine ?? entry . line ?? 1 ) - 1 ) ; // 0-based
173+ const pos = new vscode . Position ( line , 0 ) ;
174+ editor . selection = new vscode . Selection ( pos , pos ) ;
175+ editor . revealRange (
176+ new vscode . Range ( pos , pos ) ,
177+ vscode . TextEditorRevealType . InCenter
178+ ) ;
179+ }
180+ )
181+ ) ;
182+
171183 logger . info ( "Extension" , "...complete" ) ;
172184 } catch ( error ) {
173185 logger . error ( "Extension" , "Extension activation failed" , error ) ;
0 commit comments