'use strict' ; import { languages , window , commands , ExtensionContext , Range , TextDocument } from 'vscode' ; import { workspace } from 'vscode' ; let regex = new RegExp ( /(class=)/g , 'ig' ) ; function fullDocumentRange ( document ) { const lastLineId = document . lineCount - 1 ; return new Range ( 0 , 0 , lastLineId , document . lineAt ( lastLineId ) . text . length ) ; } export function activate ( context ) { let editor = window . activeTextEditor ; let disposable = commands . registerCommand ( 'extension.stayClassy' , ( ) => { if ( ! editor ) return ; let selection = editor . selection ; let range , text ; if ( selection . isEmpty ) { range = fullDocumentRange ( editor . document ) ; text = editor . document . getText ( ) ; } else { range = selection ; text = editor . document . getText ( selection ) ; } editor . edit ( builder => { let classyText = text . replace ( new RegExp ( /(class=)/g , 'ig' ) , 'className=' ) ; builder . replace ( range , classyText ) ; } ) ; } ) ; context . subscriptions . push ( disposable ) ; } export function deactivate ( ) { }