Skip to content

Commit b19d6af

Browse files
authored
Merge pull request microsoft#184321 from microsoft/aiday/issue176959
Hiding color picker when editor model has changed
2 parents bf9bbbb + 2efb4ae commit b19d6af

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/vs/editor/contrib/colorPicker/browser/colorHoverParticipant.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ function renderHoverParts(participant: ColorHoverParticipant | StandaloneColorPi
189189
const widget = disposables.add(new ColorPickerWidget(context.fragment, model, editor.getOption(EditorOption.pixelRatio), themeService, participant instanceof StandaloneColorPickerParticipant));
190190
context.setColorPicker(widget);
191191

192+
let editorUpdatedByColorPicker = false;
192193
let range = new Range(colorHover.range.startLineNumber, colorHover.range.startColumn, colorHover.range.endLineNumber, colorHover.range.endColumn);
193194
if (participant instanceof StandaloneColorPickerParticipant) {
194195
const color = hoverParts[0].model.color;
@@ -200,10 +201,21 @@ function renderHoverParts(participant: ColorHoverParticipant | StandaloneColorPi
200201
} else {
201202
disposables.add(model.onColorFlushed(async (color: Color) => {
202203
await _updateColorPresentations(editorModel, model, color, range, colorHover);
204+
editorUpdatedByColorPicker = true;
203205
range = _updateEditorModel(editor, range, model, context);
204206
}));
205207
}
206-
disposables.add(model.onDidChangeColor((color: Color) => { _updateColorPresentations(editorModel, model, color, range, colorHover); }));
208+
disposables.add(model.onDidChangeColor((color: Color) => {
209+
_updateColorPresentations(editorModel, model, color, range, colorHover);
210+
}));
211+
disposables.add(editor.onDidChangeModelContent((e) => {
212+
if (editorUpdatedByColorPicker) {
213+
editorUpdatedByColorPicker = false;
214+
} else {
215+
context.hide();
216+
editor.focus();
217+
}
218+
}));
207219
return disposables;
208220
}
209221

0 commit comments

Comments
 (0)