@@ -196,7 +196,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
196196
197197 vscode . window . registerTreeDataProvider ( "ObjectScriptExplorer" , explorerProvider ) ;
198198
199- panel = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left ) ;
199+ posPanel = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 0 ) ;
200+ posPanel . show ( ) ;
201+
202+ panel = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 1 ) ;
200203
201204 const debugAdapterFactory = new ObjectScriptDebugAdapterDescriptorFactory ( ) ;
202205
@@ -217,10 +220,33 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
217220 } ) ;
218221
219222 vscode . window . onDidChangeActiveTextEditor ( ( textEditor : vscode . TextEditor ) => {
220- if ( config ( "autoPreviewXML" ) ) {
223+ posPanel . text = "" ;
224+ if ( textEditor . document . fileName . endsWith ( ".xml" ) && config ( "autoPreviewXML" ) ) {
221225 return xml2doc ( context , textEditor ) ;
222226 }
223227 } ) ;
228+ vscode . window . onDidChangeTextEditorSelection ( ( event : vscode . TextEditorSelectionChangeEvent ) => {
229+ posPanel . text = "" ;
230+ const intMatch = event . textEditor . document . fileName . match ( / \/ ? ( .* ) \. i n t $ / i) ;
231+ if ( ! intMatch || event . selections . length > 1 || ! event . selections [ 0 ] . isEmpty ) {
232+ return ;
233+ }
234+ const line = event . selections [ 0 ] . start . line ;
235+ const [ , routine ] = intMatch ;
236+ const { document } = event . textEditor ;
237+ let label = "" ;
238+ let pos = 0 ;
239+ for ( let i = line ; i > 0 ; i -- ) {
240+ const labelMatch = document . lineAt ( i ) . text . match ( / ^ ( \w + ) .* / ) ;
241+ if ( labelMatch ) {
242+ [ , label ] = labelMatch ;
243+ break ;
244+ }
245+ pos ++ ;
246+ }
247+ event . textEditor . document . getText ;
248+ posPanel . text = `${ label } ${ pos > 0 ? "+" + pos : "" } ^${ routine } ` ;
249+ } ) ;
224250
225251 const documentSelector = ( ...list ) =>
226252 [ "file" , ...schemas ] . reduce ( ( acc , scheme ) => acc . concat ( list . map ( language => ( { scheme, language } ) ) ) , [ ] ) ;
0 commit comments