本文整理汇总了TypeScript中vscode-languageserver-protocol.Range类的典型用法代码示例。如果您正苦于以下问题:TypeScript Range类的具体用法?TypeScript Range怎么用?TypeScript Range使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Range类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should add matches to ranges', async () => {
let doc = await helper.createDocument()
let buf = doc.buffer
let lines = [
'a'.repeat(30),
'b'.repeat(30),
'c'.repeat(30),
'd'.repeat(30)
]
await buf.setLines(lines, { start: 0, end: -1 })
await helper.wait(100)
let ranges: Range[] = [
Range.create(0, 0, 0, 10),
Range.create(1, 0, 2, 10),
Range.create(3, 0, 4, 0)]
nvim.pauseNotification()
doc.matchAddRanges(ranges, 'Search')
await nvim.resumeNotification()
let res = await nvim.call('getmatches')
let item = res.find(o => o.group == 'Search')
expect(item).toBeDefined()
expect(item.pos1).toEqual([1, 1, 10])
expect(item.pos2).toEqual([2, 1, 30])
expect(item.pos3).toEqual([3, 1, 10])
expect(item.pos4).toEqual([4, 1, 30])
})
示例2: it
it('should get word range', async () => {
await helper.createDocument()
await nvim.setLine('foo bar')
await helper.wait(30)
let doc = await workspace.document
let range = doc.getWordRangeAtPosition({ line: 0, character: 0 })
expect(range).toEqual(Range.create(0, 0, 0, 3))
range = doc.getWordRangeAtPosition({ line: 0, character: 3 })
expect(range).toBeNull()
range = doc.getWordRangeAtPosition({ line: 0, character: 4 })
expect(range).toEqual(Range.create(0, 4, 0, 7))
range = doc.getWordRangeAtPosition({ line: 0, character: 7 })
expect(range).toBeNull()
})
示例3: it
it('should deactivate when change outside placeholder', async () => {
let buf = await helper.edit()
let session = new SnippetSession(nvim, buf.id)
await session.start('a${1:b}c')
let doc = await workspace.document
await doc.applyEdits(nvim, [{
range: Range.create(0, 0, 0, 1),
newText: ''
}])
await session.synchronizeUpdatedPlaceholders({
range: Range.create(0, 0, 0, 1),
text: ''
})
expect(session.isActive).toBe(false)
})
示例4: getColor
provideDocumentColors: (
_document: TextDocument,
_token: CancellationToken
): ProviderResult<ColorInformation[]> => {
if (state == 'empty') return []
if (state == 'error') return Promise.reject(new Error('no color'))
return [{
range: Range.create(0, 0, 0, 7),
color: getColor(255, 255, 255)
}]
}