本文整理汇总了TypeScript中vscode.window.onDidChangeTextEditorVisibleRanges方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.onDidChangeTextEditorVisibleRanges方法的具体用法?TypeScript window.onDidChangeTextEditorVisibleRanges怎么用?TypeScript window.onDidChangeTextEditorVisibleRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.onDidChangeTextEditorVisibleRanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: imageDecorator
//.........这里部分代码省略.........
}
} catch (error) {
result = Promise.resolve(fallback(markedString(item.imagePath)));
}
}
}
return result;
}
};
const refreshAllVisibleEditors = () => {
vscode.window.visibleTextEditors
.map(p => p.document)
.filter(p => p != null)
.forEach(doc => throttledScan(doc));
};
const getDocumentDecorators = (document: vscode.TextDocument): ScanResult => {
const scanResult = scanResults[document.uri.toString()] || {
decorations: [],
token: new vscode.CancellationTokenSource()
};
scanResults[document.uri.toString()] = scanResult;
return scanResult;
};
const scan = (document: vscode.TextDocument) => {
const editors = findEditorsForDocument(document);
if (editors.length > 0) {
const showImagePreviewOnGutter = getConfiguredProperty(document, 'showImagePreviewOnGutter', true);
const visibleLines = [];
for (const editor of editors) {
for (const range of editor.visibleRanges) {
let lineIndex = range.start.line;
while (lineIndex <= range.end.line) {
visibleLines.push(lineIndex);
lineIndex++;
}
}
}
const scanResult = getDocumentDecorators(document);
scanResult.token.cancel();
scanResult.token = new vscode.CancellationTokenSource();
decoratorProvider(document, visibleLines, scanResult.token.token)
.then(symbolResponse => {
const scanResult = getDocumentDecorators(document);
clearEditorDecorations(document, scanResult.decorations.map(p => p.textEditorDecorationType));
scanResult.decorations.length = 0;
symbolResponse.images.forEach(p => {
editors.forEach(editor =>
decorate(showImagePreviewOnGutter, editor, p, scanResult.decorations)
);
});
})
.catch(e => {
console.error(e);
});
}
};
context.subscriptions.push(vscode.languages.registerHoverProvider(['*'], hoverProvider));
context.subscriptions.push(
vscode.workspace.onDidChangeTextDocument(e => {
if (e) {
throttledScan(e.document);
}
})
);
context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor(e => {
if (e) {
throttledScan(e.document);
}
})
);
context.subscriptions.push(
vscode.workspace.onDidChangeWorkspaceFolders(() => {
refreshAllVisibleEditors();
})
);
context.subscriptions.push(
vscode.window.onDidChangeTextEditorVisibleRanges(event => {
if (event && event.textEditor && event.textEditor.document) {
const document = event.textEditor.document;
throttledScan(document, 50);
}
})
);
context.subscriptions.push(
vscode.workspace.onDidOpenTextDocument(e => {
if (e) {
throttledScan(e);
}
})
);
refreshAllVisibleEditors();
}