mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
[css] color decorator initially not shown in all editors
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -50,11 +50,13 @@ export function activate(context: ExtensionContext) {
|
||||
// client can be deactivated on extension deactivation
|
||||
context.subscriptions.push(disposable);
|
||||
|
||||
let colorRequestor = (uri: string) => {
|
||||
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange));
|
||||
};
|
||||
disposable = activateColorDecorations(colorRequestor, { css: true, scss: true, less: true });
|
||||
context.subscriptions.push(disposable);
|
||||
client.onReady().then(_ => {
|
||||
let colorRequestor = (uri: string) => {
|
||||
return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange));
|
||||
};
|
||||
disposable = activateColorDecorations(colorRequestor, { css: true, scss: true, less: true });
|
||||
context.subscriptions.push(disposable);
|
||||
});
|
||||
|
||||
languages.setLanguageConfiguration('css', {
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g
|
||||
|
||||
Reference in New Issue
Block a user