'use strict' ; import * as vscode from 'vscode' ; import { MarkdownIndex } from './MarkdownIndex' ; export function activate ( context ) { let disposable = vscode . commands . registerCommand ( 'extension.addMarkdownIndex' , ( ) => { var editor = vscode . window . activeTextEditor ; if ( ! editor ) { vscode . window . showInformationMessage ( 'No open text editor' ) ; return ; } var selection = editor . selection ; var text = editor . document . getText ( selection ) ; var lines ; if ( text . length == 0 ) { lines = editor . document . getText ( ) . split ( "\n" ) ; selection = new vscode . Selection ( 0 , 0 , lines . length , 0 ) ; } else { lines = text . split ( "\n" ) ; } const markdownIndex = new MarkdownIndex ( ) ; markdownIndex . addMarkdownIndex ( lines ) ; editor . edit ( function ( builder ) { var resultText = lines . join ( "\n" ) ; builder . replace ( new vscode . Range ( selection . start , selection . end ) , resultText ) ; } ) ; } ) ; context . subscriptions . push ( disposable ) ; } export function deactivate ( ) { }