(context: vscode.ExtensionContext, handleLocal: boolean = true)
| 94 | * The extension's entry point |
| 95 | */ |
| 96 | export async function activate(context: vscode.ExtensionContext, handleLocal: boolean = true) { |
| 97 | ExCommandLine.parser = exCommandParser; |
| 98 | |
| 99 | Logger.init(); |
| 100 | |
| 101 | // before we do anything else, we need to load the configuration |
| 102 | await loadConfiguration(); |
| 103 | |
| 104 | Logger.debug('Start'); |
| 105 | |
| 106 | extensionContext = context; |
| 107 | extensionContext.subscriptions.push(StatusBar); |
| 108 | |
| 109 | // Load state |
| 110 | Register.loadFromDisk(handleLocal); |
| 111 | await Promise.all([ExCommandLine.loadHistory(context), SearchCommandLine.loadHistory(context)]); |
| 112 | |
| 113 | const document = vscode.window.activeTextEditor?.document; |
| 114 | if (document) { |
| 115 | const filepathComponents = document.fileName.split(/\\|\//); |
| 116 | Register.setReadonlyRegister('%', filepathComponents.at(-1)!); |
| 117 | } |
| 118 | |
| 119 | // workspace events |
| 120 | registerEventListener( |
| 121 | context, |
| 122 | vscode.workspace.onDidChangeConfiguration, |
| 123 | async () => { |
| 124 | Logger.info('Configuration changed'); |
| 125 | await loadConfiguration(); |
| 126 | }, |
| 127 | false, |
| 128 | ); |
| 129 | |
| 130 | registerEventListener(context, vscode.workspace.onDidChangeTextDocument, async (event) => { |
| 131 | if (event.document.uri.scheme === 'output') { |
| 132 | // Without this, we'll get an infinite logging loop |
| 133 | return; |
| 134 | } |
| 135 | if (event.contentChanges.length === 0) { |
| 136 | // This happens when the document is saved |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | Logger.debug( |
| 141 | `${event.contentChanges.length} change(s) to ${event.document.fileName} because ${event.reason}`, |
| 142 | ); |
| 143 | for (const x of event.contentChanges) { |
| 144 | Logger.trace(`\t-${x.rangeLength}, +'${x.text}'`); |
| 145 | } |
| 146 | |
| 147 | for (const change of event.contentChanges) { |
| 148 | if (change.rangeLength > 0) { |
| 149 | globalState.jumpTracker.handleTextDeleted(event.document, change.range); |
| 150 | } |
| 151 | if (change.text.length > 0) { |
| 152 | globalState.jumpTracker.handleTextAdded(event.document, change.range.start, change.text); |
| 153 | } |
nothing calls this directly
no test coverage detected