Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e0ca7167
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e0ca7167
编写于
1月 06, 2019
作者:
J
JimiC
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ability to reload themes without restarting the editor
上级
4fd5c099
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
38 deletion
+101
-38
src/vs/workbench/services/themes/electron-browser/colorThemeData.ts
...kbench/services/themes/electron-browser/colorThemeData.ts
+14
-8
src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
...nch/services/themes/electron-browser/fileIconThemeData.ts
+19
-13
src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts
...services/themes/electron-browser/workbenchThemeService.ts
+68
-17
未找到文件。
src/vs/workbench/services/themes/electron-browser/colorThemeData.ts
浏览文件 @
e0ca7167
...
@@ -135,15 +135,21 @@ export class ColorThemeData implements IColorTheme {
...
@@ -135,15 +135,21 @@ export class ColorThemeData implements IColorTheme {
}
}
public
ensureLoaded
(
fileService
:
IFileService
):
Promise
<
void
>
{
public
ensureLoaded
(
fileService
:
IFileService
):
Promise
<
void
>
{
if
(
!
this
.
isLoaded
)
{
return
!
this
.
isLoaded
?
this
.
load
(
fileService
)
:
Promise
.
resolve
(
undefined
);
if
(
this
.
location
)
{
}
return
_loadColorTheme
(
fileService
,
this
.
location
,
this
.
themeTokenColors
,
this
.
colorMap
).
then
(
_
=>
{
this
.
isLoaded
=
true
;
public
reload
(
fileService
:
IFileService
):
Promise
<
void
>
{
this
.
sanitizeTokenColors
();
return
this
.
load
(
fileService
);
});
}
}
private
load
(
fileService
:
IFileService
):
Promise
<
void
>
{
if
(
!
this
.
location
)
{
return
Promise
.
resolve
(
undefined
);
}
}
return
Promise
.
resolve
(
undefined
);
return
_loadColorTheme
(
fileService
,
this
.
location
,
this
.
themeTokenColors
,
this
.
colorMap
).
then
(
_
=>
{
this
.
isLoaded
=
true
;
this
.
sanitizeTokenColors
();
});
}
}
/**
/**
...
...
src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
浏览文件 @
e0ca7167
...
@@ -29,20 +29,26 @@ export class FileIconThemeData implements IFileIconTheme {
...
@@ -29,20 +29,26 @@ export class FileIconThemeData implements IFileIconTheme {
private
constructor
()
{
}
private
constructor
()
{
}
public
ensureLoaded
(
fileService
:
IFileService
):
Promise
<
string
>
{
public
ensureLoaded
(
fileService
:
IFileService
):
Promise
<
string
>
{
if
(
!
this
.
isLoaded
)
{
return
!
this
.
isLoaded
?
this
.
load
(
fileService
)
:
Promise
.
resolve
(
this
.
styleSheetContent
);
if
(
this
.
location
)
{
}
return
_loadIconThemeDocument
(
fileService
,
this
.
location
).
then
(
iconThemeDocument
=>
{
let
result
=
_processIconThemeDocument
(
this
.
id
,
this
.
location
!
,
iconThemeDocument
);
public
reload
(
fileService
:
IFileService
):
Promise
<
string
>
{
this
.
styleSheetContent
=
result
.
content
;
return
this
.
load
(
fileService
);
this
.
hasFileIcons
=
result
.
hasFileIcons
;
}
this
.
hasFolderIcons
=
result
.
hasFolderIcons
;
this
.
hidesExplorerArrows
=
result
.
hidesExplorerArrows
;
private
load
(
fileService
:
IFileService
):
Promise
<
string
>
{
this
.
isLoaded
=
true
;
if
(
!
this
.
location
)
{
return
this
.
styleSheetContent
;
return
Promise
.
resolve
(
this
.
styleSheetContent
);
});
}
}
}
return
Promise
.
resolve
(
this
.
styleSheetContent
);
return
_loadIconThemeDocument
(
fileService
,
this
.
location
).
then
(
iconThemeDocument
=>
{
const
result
=
_processIconThemeDocument
(
this
.
id
,
this
.
location
!
,
iconThemeDocument
);
this
.
styleSheetContent
=
result
.
content
;
this
.
hasFileIcons
=
result
.
hasFileIcons
;
this
.
hasFolderIcons
=
result
.
hasFolderIcons
;
this
.
hidesExplorerArrows
=
result
.
hidesExplorerArrows
;
this
.
isLoaded
=
true
;
return
this
.
styleSheetContent
;
});
}
}
static
fromExtensionTheme
(
iconTheme
:
IThemeExtensionPoint
,
iconThemeLocation
:
URI
,
extensionData
:
ExtensionData
):
FileIconThemeData
{
static
fromExtensionTheme
(
iconTheme
:
IThemeExtensionPoint
,
iconThemeLocation
:
URI
,
extensionData
:
ExtensionData
):
FileIconThemeData
{
...
...
src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts
浏览文件 @
e0ca7167
...
@@ -26,7 +26,7 @@ import { FileIconThemeData } from 'vs/workbench/services/themes/electron-browser
...
@@ -26,7 +26,7 @@ import { FileIconThemeData } from 'vs/workbench/services/themes/electron-browser
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
removeClasses
,
addClasses
}
from
'
vs/base/browser/dom
'
;
import
{
removeClasses
,
addClasses
}
from
'
vs/base/browser/dom
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
,
FileChangeType
}
from
'
vs/platform/files/common/files
'
;
// implementation
// implementation
...
@@ -72,10 +72,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
...
@@ -72,10 +72,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
private
currentColorTheme
:
ColorThemeData
;
private
currentColorTheme
:
ColorThemeData
;
private
container
:
HTMLElement
;
private
container
:
HTMLElement
;
private
readonly
onColorThemeChange
:
Emitter
<
IColorTheme
>
;
private
readonly
onColorThemeChange
:
Emitter
<
IColorTheme
>
;
private
onColorThemeFileChangeListener
:
IDisposable
;
private
iconThemeStore
:
FileIconThemeStore
;
private
iconThemeStore
:
FileIconThemeStore
;
private
currentIconTheme
:
IFileIconTheme
;
private
currentIconTheme
:
IFileIconTheme
;
private
readonly
onFileIconThemeChange
:
Emitter
<
IFileIconTheme
>
;
private
readonly
onFileIconThemeChange
:
Emitter
<
IFileIconTheme
>
;
private
onIconThemeFileChangeListener
:
IDisposable
;
private
themingParticipantChangeListener
:
IDisposable
;
private
themingParticipantChangeListener
:
IDisposable
;
private
_configurationWriter
:
ConfigurationWriter
;
private
_configurationWriter
:
ConfigurationWriter
;
...
@@ -279,27 +281,54 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
...
@@ -279,27 +281,54 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return
this
.
writeColorThemeConfiguration
(
settingsTarget
);
return
this
.
writeColorThemeConfiguration
(
settingsTarget
);
}
}
const
onApply
=
(
themeData
:
ColorThemeData
)
=>
{
// determine which color theme file to monitor for changes
if
(
this
.
fileService
)
{
const
_currentColorThemeData
=
this
.
currentColorTheme
as
ColorThemeData
;
if
(
!
this
.
onColorThemeFileChangeListener
)
{
this
.
onColorThemeFileChangeListener
=
this
.
fileService
.
onFileChanges
(
e
=>
{
return
e
.
contains
(
themeData
.
location
,
FileChangeType
.
UPDATED
)
&&
themeData
.
reload
(
this
.
fileService
)
.
then
(
_
=>
{
themeData
.
setCustomColors
(
this
.
colorCustomizations
);
themeData
.
setCustomTokenColors
(
this
.
tokenColorCustomizations
);
this
.
updateDynamicCSSRules
(
themeData
);
});
});
}
// stop monitoring previous color theme file for changes
if
(
_currentColorThemeData
.
location
)
{
this
.
fileService
.
unwatchFileChanges
(
_currentColorThemeData
.
location
);
}
// start monitoring new color theme file for changes
if
(
themeData
.
location
)
{
this
.
fileService
.
watchFileChanges
(
themeData
.
location
);
}
}
};
themeId
=
validateThemeId
(
themeId
);
// migrate theme ids
themeId
=
validateThemeId
(
themeId
);
// migrate theme ids
return
this
.
colorThemeStore
.
findThemeData
(
themeId
,
DEFAULT_THEME_ID
).
then
(
themeData
=>
{
return
this
.
colorThemeStore
.
findThemeData
(
themeId
,
DEFAULT_THEME_ID
).
then
(
themeData
=>
{
if
(
themeData
)
{
if
(
!
themeData
)
{
return
themeData
.
ensureLoaded
(
this
.
fileService
).
then
(
_
=>
{
return
null
;
if
(
themeId
===
this
.
currentColorTheme
.
id
&&
!
this
.
currentColorTheme
.
isLoaded
&&
this
.
currentColorTheme
.
hasEqualData
(
themeData
))
{
}
// the loaded theme is identical to the perisisted theme. Don't need to send an event.
return
themeData
.
ensureLoaded
(
this
.
fileService
).
then
(
_
=>
{
this
.
currentColorTheme
=
themeData
;
onApply
(
themeData
);
themeData
.
setCustomColors
(
this
.
colorCustomizations
);
if
(
themeId
===
this
.
currentColorTheme
.
id
&&
!
this
.
currentColorTheme
.
isLoaded
&&
this
.
currentColorTheme
.
hasEqualData
(
themeData
))
{
themeData
.
setCustomTokenColors
(
this
.
tokenColorCustomizations
);
// the loaded theme is identical to the perisisted theme. Don't need to send an event.
return
Promise
.
resolve
(
themeData
);
this
.
currentColorTheme
=
themeData
;
}
themeData
.
setCustomColors
(
this
.
colorCustomizations
);
themeData
.
setCustomColors
(
this
.
colorCustomizations
);
themeData
.
setCustomTokenColors
(
this
.
tokenColorCustomizations
);
themeData
.
setCustomTokenColors
(
this
.
tokenColorCustomizations
);
this
.
updateDynamicCSSRules
(
themeData
);
return
Promise
.
resolve
(
themeData
);
return
this
.
applyTheme
(
themeData
,
settingsTarget
);
}
},
error
=>
{
themeData
.
setCustomColors
(
this
.
colorCustomizations
);
return
Promise
.
reject
(
new
Error
(
nls
.
localize
(
'
error.cannotloadtheme
'
,
"
Unable to load {0}: {1}
"
,
themeData
.
location
.
toString
(),
error
.
message
)));
themeData
.
setCustomTokenColors
(
this
.
tokenColorCustomizations
);
});
this
.
updateDynamicCSSRules
(
themeData
);
}
return
this
.
applyTheme
(
themeData
,
settingsTarget
);
return
null
;
},
error
=>
{
return
Promise
.
reject
(
new
Error
(
nls
.
localize
(
'
error.cannotloadtheme
'
,
"
Unable to load {0}: {1}
"
,
themeData
.
location
.
toString
(),
error
.
message
)));
});
});
});
}
}
...
@@ -408,6 +437,28 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
...
@@ -408,6 +437,28 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return
this
.
writeFileIconConfiguration
(
settingsTarget
);
return
this
.
writeFileIconConfiguration
(
settingsTarget
);
}
}
let
onApply
=
(
newIconTheme
:
FileIconThemeData
)
=>
{
let
onApply
=
(
newIconTheme
:
FileIconThemeData
)
=>
{
// determine which icon theme file to monitor for changes
if
(
this
.
currentIconTheme
.
id
!==
newIconTheme
.
id
||
!
this
.
currentIconTheme
.
isLoaded
)
{
if
(
this
.
fileService
)
{
if
(
!
this
.
onIconThemeFileChangeListener
)
{
this
.
onIconThemeFileChangeListener
=
this
.
fileService
.
onFileChanges
(
e
=>
{
return
e
.
contains
(
newIconTheme
.
location
,
FileChangeType
.
UPDATED
)
&&
newIconTheme
.
reload
(
this
.
fileService
)
.
then
(
_
=>
_applyIconTheme
(
newIconTheme
,
()
=>
Promise
.
resolve
(
this
.
currentIconTheme
)));
});
}
const
_currentIconThemeData
=
this
.
currentIconTheme
as
FileIconThemeData
;
// stop monitoring previous icon theme file for changes
if
(
_currentIconThemeData
.
location
)
{
this
.
fileService
.
unwatchFileChanges
(
_currentIconThemeData
.
location
);
}
// start monitoring new icon theme file for changes
if
(
newIconTheme
.
location
)
{
this
.
fileService
.
watchFileChanges
(
newIconTheme
.
location
);
}
}
}
this
.
doSetFileIconTheme
(
newIconTheme
);
this
.
doSetFileIconTheme
(
newIconTheme
);
// remember theme data for a quick restore
// remember theme data for a quick restore
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录