mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
[html] improve color decorator updating
This commit is contained in:
parent
d2f8a45adc
commit
3358b26968
|
@ -32,24 +32,20 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
|
|||
|
||||
let pendingUpdateRequests: { [key: string]: NodeJS.Timer; } = {};
|
||||
|
||||
window.onDidChangeVisibleTextEditors(editors => {
|
||||
for (let editor of editors) {
|
||||
triggerUpdateDecorations(editor.document);
|
||||
}
|
||||
}, null, disposables);
|
||||
|
||||
workspace.onDidChangeTextDocument(event => triggerUpdateDecorations(event.document), null, disposables);
|
||||
|
||||
// we care about all visible editors
|
||||
window.visibleTextEditors.forEach(editor => {
|
||||
if (editor.document) {
|
||||
triggerUpdateDecorations(editor.document);
|
||||
}
|
||||
});
|
||||
// to get visible one has to become active
|
||||
window.onDidChangeActiveTextEditor(editor => {
|
||||
if (editor) {
|
||||
triggerUpdateDecorations(editor.document);
|
||||
}
|
||||
}, null, disposables);
|
||||
|
||||
workspace.onDidChangeTextDocument(event => triggerUpdateDecorations(event.document), null, disposables);
|
||||
workspace.onDidOpenTextDocument(triggerUpdateDecorations, null, disposables);
|
||||
workspace.onDidCloseTextDocument(triggerUpdateDecorations, null, disposables);
|
||||
|
||||
workspace.textDocuments.forEach(triggerUpdateDecorations);
|
||||
|
||||
function triggerUpdateDecorations(document: TextDocument) {
|
||||
let triggerUpdate = supportedLanguages[document.languageId];
|
||||
|
@ -78,6 +74,7 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
|
|||
decoratorProvider(contentUri).then(ranges => {
|
||||
for (let editor of window.visibleTextEditors) {
|
||||
let document = editor.document;
|
||||
|
||||
if (document && document.version === documentVersion && contentUri === document.uri.toString()) {
|
||||
let decorations = ranges.slice(0, MAX_DECORATORS).map(range => {
|
||||
let color = document.getText(range);
|
||||
|
|
Loading…
Reference in a new issue