import { DecorationOptions , EndOfLine , Position , Range , Selection , SnippetString , TextEditor , TextEditorDecorationType , TextEditorEdit , TextEditorOptions , TextEditorRevealType , Uri , ViewColumn } from "vscode" ; import { DeploymentTemplateDoc } from "../../extension.bundle" ; import { TextDocumentFake } from "./TextDocumentFake" ; class EditBuilder implements TextEditorEdit { public constructor ( public readonly textEditorFake ) { } public replace ( location , value ) { throw new Error ( "Method not implemented." ) ; } public insert ( location , value ) { const dt = new DeploymentTemplateDoc ( this . textEditorFake . document . _textBuffer , Uri . file ( "/template.json" ) , 0 ) ; const index = dt . getDocumentCharacterIndex ( location . line , location . character ) ; const newText = this . textEditorFake . document . _textBuffer . slice ( 0 , index ) + value + this . textEditorFake . document . _textBuffer . slice ( index ) ; this . textEditorFake . document . _textBuffer = newText ; } public delete ( location ) { throw new Error ( "Method not implemented." ) ; } public setEndOfLine ( endOfLine ) { throw new Error ( "Method not implemented." ) ; } } export class TextEditorFake implements TextEditor { public constructor ( public readonly document ) { } public selection : Selection = new Selection ( new Position ( 0 , 0 ) , new Position ( 0 , 0 ) ) ; public selections : Selection [ ] = [ ] ; public visibleRanges : Range [ ] = [ ] ; public options : TextEditorOptions = { } ; public viewColumn : ViewColumn = ViewColumn . One ; public async edit ( callback , options ? ) { const builder = new EditBuilder ( this ) ; callback ( builder ) ; return true ; } public insertSnippet ( snippet , location ? , options ? ) { throw new Error ( "Method not implemented." ) ; } public setDecorations ( decorationType , rangesOrOptions ) { throw new Error ( "Method not implemented." ) ; } public revealRange ( range , revealType ? ) { throw new Error ( "Method not implemented." ) ; } public show ( column ? ) { throw new Error ( "Method not implemented." ) ; } public hide ( ) { throw new Error ( "Method not implemented." ) ; } }