本文整理汇总了TypeScript中atom.TextBuffer.onDidSave方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextBuffer.onDidSave方法的具体用法?TypeScript TextBuffer.onDidSave怎么用?TypeScript TextBuffer.onDidSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atom.TextBuffer
的用法示例。
在下文中一共展示了TextBuffer.onDidSave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: registerCompletionBuffer
/*
registerCompletionBuffer(buffer)
Every buffer that would be used with autocompletion functions has to
be registered with this function.
buffer: TextBuffer, buffer to be used in autocompletion
Returns: Disposable, which will remove buffer from autocompletion
*/
public registerCompletionBuffer(buffer: TextBuffer) {
if (!this.isActive) { throw new Error('Backend inactive') }
if (this.bufferMap.has(buffer)) {
return new Disposable(() => { /* void */ })
}
this.bufferMap.set(buffer, new BufferInfo(buffer))
const file = buffer.getUri()
buffer.onDidSave(async (_event) => {
const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
if (buf) {
delete buf.completions
}
const contents: string = buffer.getText()
await this.process.backend.setFileContents(file, contents)
await this.process.backend.scanFile({ file, scanProject: false, scanDeps: false })
})
setImmediate(async () => {
this.process.backend.scanFile({ file })
})
return new Disposable(() =>
this.unregisterCompletionBuffer(buffer))
}