@@ -19,11 +19,12 @@ import * as vscode from 'vscode';
1919import { MAN_COMMAND_REGEX } from './consts' ;
2020import ManpageDocument from './manpageDocument' ;
2121import child_process = require( 'child_process' ) ;
22+ import { Logging } from './logging' ;
2223
2324export class ManpageContentView {
2425 constructor ( context : vscode . ExtensionContext ) {
25-
26- const provider = new ManpageContentProvider ( ) ;
26+ const logger = new Logging ( context ) ;
27+ const provider = new ManpageContentProvider ( context ) ;
2728
2829 // register content provider
2930 const providerRegistrations = vscode . Disposable . from (
@@ -35,16 +36,20 @@ export class ManpageContentView {
3536
3637
3738 const openFromSelection = vscode . commands . registerTextEditorCommand ( 'manpages.openFromSelection' , ( editor ) => {
39+ logger . log ( `openFromSelection called with selection: ${ editor . selection . isEmpty ? 'empty' : 'not empty' } ` ) ;
3840 if ( editor . selection . isEmpty ) return ;
3941 let text = editor . document . getText ( editor . selection ) ;
42+ logger . log ( `openFromSelection selection: ${ logger . printSelection ( editor . selection ) } , text: ${ text } ` ) ;
4043 return openManPage ( text , openInActiveColumn ) ;
4144 } ) ;
4245
4346 const openFromCursor = vscode . commands . registerTextEditorCommand ( 'manpages.openFromCursor' , ( editor ) => {
47+ logger . log ( `openFromCursor called with selection: ${ editor . selection . isEmpty ? 'empty' : 'not empty' } ` ) ;
4448 if ( ! editor . selection . isEmpty ) return ;
4549 const wordRange = editor . document . getWordRangeAtPosition ( editor . selection . active , MAN_COMMAND_REGEX ) ;
4650 if ( ! wordRange ) { return ; }
4751 let text = editor . document . getText ( wordRange ) ;
52+ logger . log ( `openFromCursor wordRange: ${ logger . printRange ( wordRange ) } , text: ${ text } ` ) ;
4853 return openManPage ( text , openInActiveColumn ) ;
4954 } ) ;
5055
@@ -57,6 +62,7 @@ export class ManpageContentView {
5762 }
5863 } ) ;
5964
65+ logger . log ( `openFromInput called with text: ${ result } ` ) ;
6066 if ( result ) {
6167 return openManPage ( result , openInActiveColumn ) ;
6268 }
@@ -78,12 +84,13 @@ export class ManpageContentProvider implements vscode.TextDocumentContentProvide
7884 private _documents = new Map < string , ManpageDocument > ( ) ;
7985 private _editorDecoration = vscode . window . createTextEditorDecorationType ( { textDecoration : 'underline' } ) ;
8086 private _subscriptions : vscode . Disposable ;
87+ private _logger : Logging ;
8188
82- constructor ( ) {
83-
89+ constructor ( context : vscode . ExtensionContext ) {
8490 // Listen to the `closeTextDocument`-event which means we must
8591 // clear the corresponding model object - `ReferencesDocument`
8692 this . _subscriptions = vscode . workspace . onDidCloseTextDocument ( doc => this . _documents . delete ( doc . uri . toString ( ) ) ) ;
93+ this . _logger = new Logging ( context ) ;
8794 }
8895
8996 dispose ( ) : void {
@@ -118,6 +125,7 @@ export class ManpageContentProvider implements vscode.TextDocumentContentProvide
118125 let section = m [ 2 ] ;
119126
120127 let cmd = this . buildCmdline ( section , word ) ;
128+ this . _logger . log ( `Executing command: ${ cmd } ` ) ;
121129
122130 return new Promise ( ( resolve ) => {
123131 child_process . exec ( cmd , ( err , stdout , stderr ) => {
0 commit comments