提交 f0ecb26a 编写于 作者: R rebornix

Guess color format.

上级 3479d81d
......@@ -55,6 +55,15 @@ export class ColorPickerModel {
this._onDidChangeFormatter.fire(this.formatter);
}
guessColorFormat(color: Color, originalText: string): void {
for (let i = 0; i < this.formatters.length; i++) {
if (originalText === this.formatters[i].format(color)) {
this.formatterIndex = i;
break;
}
}
}
flushColor(): void {
this._onColorFlushed.fire(this._color);
}
......
......@@ -315,6 +315,8 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
const color = new Color(rgba);
const model = new ColorPickerModel(color, 0);
const originalText = this._editor.getModel().getValueInRange(msg.range);
model.guessColorFormat(color, originalText);
const widget = new ColorPickerWidget(fragment, model, this._editor.getConfiguration().pixelRatio);
const editorModel = this._editor.getModel();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册