本文整理汇总了TypeScript中vscode-languageserver-types.TextEdit.insert方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextEdit.insert方法的具体用法?TypeScript TextEdit.insert怎么用?TypeScript TextEdit.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver-types.TextEdit
的用法示例。
在下文中一共展示了TextEdit.insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('replace', function (): any {
let input = TextDocument.create('foo://bar/f', 'html', 0, '012345678901234567890123456789');
assert.equal(applyEdits(input, [TextEdit.replace(Range.create(Position.create(0, 3), Position.create(0, 6)), 'Hello')]), '012Hello678901234567890123456789');
assert.equal(applyEdits(input, [TextEdit.replace(Range.create(Position.create(0, 3), Position.create(0, 6)), 'Hello'), TextEdit.replace(Range.create(Position.create(0, 6), Position.create(0, 9)), 'World')]), '012HelloWorld901234567890123456789');
assert.equal(applyEdits(input, [TextEdit.replace(Range.create(Position.create(0, 3), Position.create(0, 6)), 'Hello'), TextEdit.insert(Position.create(0, 6), 'World')]), '012HelloWorld678901234567890123456789');
assert.equal(applyEdits(input, [TextEdit.insert(Position.create(0, 6), 'World'), TextEdit.replace(Range.create(Position.create(0, 3), Position.create(0, 6)), 'Hello')]), '012HelloWorld678901234567890123456789');
assert.equal(applyEdits(input, [TextEdit.insert(Position.create(0, 3), 'World'), TextEdit.replace(Range.create(Position.create(0, 3), Position.create(0, 6)), 'Hello')]), '012WorldHello678901234567890123456789');
});
示例2: it
it('should return false for change to file not exists', async () => {
let uri = URI.file('/tmp/not_exists').toString()
let versioned = VersionedTextDocumentIdentifier.create(uri, null)
let edit = TextEdit.insert(Position.create(0, 0), 'bar')
let documentChanges = [TextDocumentEdit.create(versioned, [edit])]
let res = await workspace.applyEdit({ documentChanges })
expect(res).toBe(false)
})
示例3: async
provideCompletionItems: async (
_document: TextDocument,
_position: Position,
_token: CancellationToken,
_context: CompletionContext
): Promise<CompletionItem[]> => {
return [{
label: 'foo',
filterText: 'foo',
additionalTextEdits: [TextEdit.insert(Position.create(0, 0), 'a\nbar')]
}]
}