Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f1a1fd24
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1a1fd24
编写于
2月 22, 2017
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[css] Setting to hide CSS Color preview boxes. Fixes #10943
上级
403f29a9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
97 addition
and
19 deletion
+97
-19
extensions/css/client/src/colorDecorators.ts
extensions/css/client/src/colorDecorators.ts
+39
-9
extensions/css/package.json
extensions/css/package.json
+15
-0
extensions/css/package.nls.json
extensions/css/package.nls.json
+4
-1
extensions/html/client/src/colorDecorators.ts
extensions/html/client/src/colorDecorators.ts
+39
-9
未找到文件。
extensions/css/client/src/colorDecorators.ts
浏览文件 @
f1a1fd24
...
...
@@ -30,6 +30,11 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
let
colorsDecorationType
=
window
.
createTextEditorDecorationType
(
decorationType
);
disposables
.
push
(
colorsDecorationType
);
let
decoratorEnablement
=
{};
for
(
let
languageId
in
supportedLanguages
)
{
decoratorEnablement
[
languageId
]
=
isDecoratorEnabled
(
languageId
);
}
let
pendingUpdateRequests
:
{
[
key
:
string
]:
NodeJS
.
Timer
;
}
=
{};
window
.
onDidChangeVisibleTextEditors
(
editors
=>
{
...
...
@@ -40,28 +45,53 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
workspace
.
onDidChangeTextDocument
(
event
=>
triggerUpdateDecorations
(
event
.
document
),
null
,
disposables
);
// we care about all visible editors
window
.
visibleTextEditors
.
forEach
(
editor
=>
{
if
(
editor
.
document
)
{
triggerUpdateDecorations
(
editor
.
document
);
workspace
.
onDidChangeConfiguration
(
_
=>
{
let
hasChanges
=
false
;
for
(
let
languageId
in
supportedLanguages
)
{
let
prev
=
decoratorEnablement
[
languageId
];
let
curr
=
isDecoratorEnabled
(
languageId
);
if
(
prev
!==
curr
)
{
decoratorEnablement
[
languageId
]
=
curr
;
hasChanges
=
true
;
}
}
});
if
(
hasChanges
)
{
updateAllVisibleEditors
(
true
);
}
},
null
,
disposables
);
updateAllVisibleEditors
(
false
);
function
isDecoratorEnabled
(
languageId
:
string
)
{
return
workspace
.
getConfiguration
().
get
<
boolean
>
(
languageId
+
'
.colorDecorators.enable
'
);
}
function
updateAllVisibleEditors
(
settingsChanges
:
boolean
)
{
window
.
visibleTextEditors
.
forEach
(
editor
=>
{
if
(
editor
.
document
)
{
triggerUpdateDecorations
(
editor
.
document
,
settingsChanges
);
}
});
}
function
triggerUpdateDecorations
(
document
:
TextDocument
)
{
let
triggerUpdate
=
supportedLanguages
[
document
.
languageId
];
function
triggerUpdateDecorations
(
document
:
TextDocument
,
settingsChanges
=
false
)
{
let
triggerUpdate
=
supportedLanguages
[
document
.
languageId
]
&&
(
decoratorEnablement
[
document
.
languageId
]
||
settingsChanges
)
;
let
documentUri
=
document
.
uri
;
let
documentUriStr
=
documentUri
.
toString
();
let
timeout
=
pendingUpdateRequests
[
documentUriStr
];
if
(
typeof
timeout
!==
'
undefined
'
)
{
clearTimeout
(
timeout
);
triggerUpdate
=
true
;
// force update, even if languageId is not supported (anymore)
}
if
(
triggerUpdate
)
{
pendingUpdateRequests
[
documentUriStr
]
=
setTimeout
(()
=>
{
// check if the document is in use by an active editor
for
(
let
editor
of
window
.
visibleTextEditors
)
{
if
(
editor
.
document
&&
documentUriStr
===
editor
.
document
.
uri
.
toString
())
{
updateDecorationForEditor
(
documentUriStr
,
editor
.
document
.
version
);
if
(
decoratorEnablement
[
document
.
languageId
])
{
updateDecorationForEditor
(
documentUriStr
,
editor
.
document
.
version
);
}
else
{
editor
.
setDecorations
(
colorsDecorationType
,
[]);
}
break
;
}
}
...
...
extensions/css/package.json
浏览文件 @
f1a1fd24
...
...
@@ -64,6 +64,11 @@
"default"
:
true
,
"description"
:
"%css.validate.desc%"
},
"css.colorDecorators.enable"
:
{
"type"
:
"boolean"
,
"default"
:
true
,
"description"
:
"%css.colorDecorators.enable.desc%"
},
"css.lint.compatibleVendorPrefixes"
:
{
"type"
:
"string"
,
"enum"
:
[
...
...
@@ -271,6 +276,11 @@
"default"
:
true
,
"description"
:
"%scss.validate.desc%"
},
"scss.colorDecorators.enable"
:
{
"type"
:
"boolean"
,
"default"
:
true
,
"description"
:
"%scss.colorDecorators.enable.desc%"
},
"scss.lint.compatibleVendorPrefixes"
:
{
"type"
:
"string"
,
"enum"
:
[
...
...
@@ -469,6 +479,11 @@
"default"
:
true
,
"description"
:
"%less.validate.desc%"
},
"less.colorDecorators.enable"
:
{
"type"
:
"boolean"
,
"default"
:
true
,
"description"
:
"%less.colorDecorators.enable.desc%"
},
"less.lint.compatibleVendorPrefixes"
:
{
"type"
:
"string"
,
"enum"
:
[
...
...
extensions/css/package.nls.json
浏览文件 @
f1a1fd24
...
...
@@ -55,5 +55,8 @@
"scss.lint.unknownVendorSpecificProperties.desc"
:
"Unknown vendor specific property."
,
"scss.lint.vendorPrefix.desc"
:
"When using a vendor-specific prefix also include the standard property"
,
"scss.lint.zeroUnits.desc"
:
"No unit for zero needed"
,
"scss.validate.desc"
:
"Enables or disables all validations"
"scss.validate.desc"
:
"Enables or disables all validations"
,
"less.colorDecorators.enable.desc"
:
"Enables or disables color decorators"
,
"scss.colorDecorators.enable.desc"
:
"Enables or disables color decorators"
,
"css.colorDecorators.enable.desc"
:
"Enables or disables color decorators"
}
\ No newline at end of file
extensions/html/client/src/colorDecorators.ts
浏览文件 @
f1a1fd24
...
...
@@ -30,6 +30,11 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
let
colorsDecorationType
=
window
.
createTextEditorDecorationType
(
decorationType
);
disposables
.
push
(
colorsDecorationType
);
let
decoratorEnablement
=
{};
for
(
let
languageId
in
supportedLanguages
)
{
decoratorEnablement
[
languageId
]
=
isDecoratorEnabled
(
languageId
);
}
let
pendingUpdateRequests
:
{
[
key
:
string
]:
NodeJS
.
Timer
;
}
=
{};
window
.
onDidChangeVisibleTextEditors
(
editors
=>
{
...
...
@@ -40,28 +45,53 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
workspace
.
onDidChangeTextDocument
(
event
=>
triggerUpdateDecorations
(
event
.
document
),
null
,
disposables
);
// we care about all visible editors
window
.
visibleTextEditors
.
forEach
(
editor
=>
{
if
(
editor
.
document
)
{
triggerUpdateDecorations
(
editor
.
document
);
workspace
.
onDidChangeConfiguration
(
_
=>
{
let
hasChanges
=
false
;
for
(
let
languageId
in
supportedLanguages
)
{
let
prev
=
decoratorEnablement
[
languageId
];
let
curr
=
isDecoratorEnabled
(
languageId
);
if
(
prev
!==
curr
)
{
decoratorEnablement
[
languageId
]
=
curr
;
hasChanges
=
true
;
}
}
});
if
(
hasChanges
)
{
updateAllVisibleEditors
(
true
);
}
},
null
,
disposables
);
updateAllVisibleEditors
(
false
);
function
isDecoratorEnabled
(
languageId
:
string
)
{
return
workspace
.
getConfiguration
().
get
<
boolean
>
(
languageId
+
'
.colorDecorators.enable
'
);
}
function
updateAllVisibleEditors
(
settingsChanges
:
boolean
)
{
window
.
visibleTextEditors
.
forEach
(
editor
=>
{
if
(
editor
.
document
)
{
triggerUpdateDecorations
(
editor
.
document
,
settingsChanges
);
}
});
}
function
triggerUpdateDecorations
(
document
:
TextDocument
)
{
let
triggerUpdate
=
supportedLanguages
[
document
.
languageId
];
function
triggerUpdateDecorations
(
document
:
TextDocument
,
settingsChanges
=
false
)
{
let
triggerUpdate
=
supportedLanguages
[
document
.
languageId
]
&&
(
decoratorEnablement
[
document
.
languageId
]
||
settingsChanges
)
;
let
documentUri
=
document
.
uri
;
let
documentUriStr
=
documentUri
.
toString
();
let
timeout
=
pendingUpdateRequests
[
documentUriStr
];
if
(
typeof
timeout
!==
'
undefined
'
)
{
clearTimeout
(
timeout
);
triggerUpdate
=
true
;
// force update, even if languageId is not supported (anymore)
}
if
(
triggerUpdate
)
{
pendingUpdateRequests
[
documentUriStr
]
=
setTimeout
(()
=>
{
// check if the document is in use by an active editor
for
(
let
editor
of
window
.
visibleTextEditors
)
{
if
(
editor
.
document
&&
documentUriStr
===
editor
.
document
.
uri
.
toString
())
{
updateDecorationForEditor
(
documentUriStr
,
editor
.
document
.
version
);
if
(
decoratorEnablement
[
document
.
languageId
])
{
updateDecorationForEditor
(
documentUriStr
,
editor
.
document
.
version
);
}
else
{
editor
.
setDecorations
(
colorsDecorationType
,
[]);
}
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录