Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6e923a9d
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,发现更多精彩内容 >>
提交
6e923a9d
编写于
12月 21, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf - avoid writing state when state did not change
上级
7024e62d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
8 deletion
+19
-8
src/vs/platform/history/electron-main/historyMainService.ts
src/vs/platform/history/electron-main/historyMainService.ts
+6
-1
src/vs/platform/menubar/electron-main/menubar.ts
src/vs/platform/menubar/electron-main/menubar.ts
+0
-4
src/vs/platform/state/node/stateService.ts
src/vs/platform/state/node/stateService.ts
+13
-3
未找到文件。
src/vs/platform/history/electron-main/historyMainService.ts
浏览文件 @
6e923a9d
...
...
@@ -180,7 +180,6 @@ export class HistoryMainService implements IHistoryMainService {
// out of sync quickly over time. the attempted fix is to always set the list fresh
// from our MRU history data. So we clear the documents first and then set the documents
// again.
app
.
clearRecentDocuments
();
const
mru
=
this
.
getRecentlyOpened
();
...
...
@@ -257,6 +256,7 @@ export class HistoryMainService implements IHistoryMainService {
if
(
workspaceOrFile
instanceof
URI
)
{
return
getComparisonKey
(
workspaceOrFile
);
}
return
workspaceOrFile
.
id
;
}
...
...
@@ -286,6 +286,7 @@ export class HistoryMainService implements IHistoryMainService {
}
}
}
if
(
Array
.
isArray
(
storedRecents
.
files2
))
{
for
(
const
file
of
storedRecents
.
files2
)
{
if
(
typeof
file
===
'
string
'
)
{
...
...
@@ -300,11 +301,13 @@ export class HistoryMainService implements IHistoryMainService {
}
}
}
return
result
;
}
private
saveRecentlyOpened
(
recent
:
IRecentlyOpened
):
void
{
const
serialized
:
ISerializedRecentlyOpened
=
{
workspaces2
:
[],
files2
:
[]
};
for
(
const
workspace
of
recent
.
workspaces
)
{
if
(
isSingleFolderWorkspaceIdentifier
(
workspace
))
{
serialized
.
workspaces2
.
push
(
workspace
.
toString
());
...
...
@@ -312,9 +315,11 @@ export class HistoryMainService implements IHistoryMainService {
serialized
.
workspaces2
.
push
(
workspace
);
}
}
for
(
const
file
of
recent
.
files
)
{
serialized
.
files2
.
push
(
file
.
toString
());
}
this
.
stateService
.
setItem
(
HistoryMainService
.
recentlyOpenedStorageKey
,
serialized
);
}
...
...
src/vs/platform/menubar/electron-main/menubar.ts
浏览文件 @
6e923a9d
...
...
@@ -93,10 +93,6 @@ export class Menubar {
}
private
restoreCachedMenubarData
()
{
// TODO@sbatten remove this at some point down the road
const
outdatedKeys
=
[
'
lastKnownAdditionalKeybindings
'
,
'
lastKnownKeybindings
'
,
'
lastKnownMenubar
'
];
outdatedKeys
.
forEach
(
key
=>
this
.
stateService
.
removeItem
(
key
));
const
menubarData
=
this
.
stateService
.
getItem
<
IMenubarData
>
(
Menubar
.
lastKnownMenubarStorageKey
);
if
(
menubarData
)
{
if
(
menubarData
.
menus
)
{
...
...
src/vs/platform/state/node/stateService.ts
浏览文件 @
6e923a9d
...
...
@@ -15,6 +15,7 @@ import { readFile } from 'vs/base/node/pfs';
export
class
FileStorage
{
private
_database
:
object
|
null
=
null
;
private
lastFlushedSerializedDatabase
:
string
|
null
=
null
;
constructor
(
private
dbPath
:
string
,
private
onError
:
(
error
:
Error
)
=>
void
)
{
}
...
...
@@ -29,7 +30,8 @@ export class FileStorage {
init
():
Promise
<
void
>
{
return
readFile
(
this
.
dbPath
).
then
(
contents
=>
{
try
{
this
.
_database
=
JSON
.
parse
(
contents
.
toString
());
this
.
lastFlushedSerializedDatabase
=
contents
.
toString
();
this
.
_database
=
JSON
.
parse
(
this
.
lastFlushedSerializedDatabase
);
}
catch
(
error
)
{
this
.
_database
=
{};
}
...
...
@@ -44,7 +46,9 @@ export class FileStorage {
private
loadSync
():
object
{
try
{
return
JSON
.
parse
(
fs
.
readFileSync
(
this
.
dbPath
).
toString
());
this
.
lastFlushedSerializedDatabase
=
fs
.
readFileSync
(
this
.
dbPath
).
toString
();
return
JSON
.
parse
(
this
.
lastFlushedSerializedDatabase
);
}
catch
(
error
)
{
if
(
error
.
code
!==
'
ENOENT
'
)
{
this
.
onError
(
error
);
...
...
@@ -93,8 +97,14 @@ export class FileStorage {
}
private
saveSync
():
void
{
const
serializedDatabase
=
JSON
.
stringify
(
this
.
database
,
null
,
4
);
if
(
serializedDatabase
===
this
.
lastFlushedSerializedDatabase
)
{
return
;
// return early if the database has not changed
}
try
{
writeFileAndFlushSync
(
this
.
dbPath
,
JSON
.
stringify
(
this
.
database
,
null
,
4
));
// permission issue can happen here
writeFileAndFlushSync
(
this
.
dbPath
,
serializedDatabase
);
// permission issue can happen here
this
.
lastFlushedSerializedDatabase
=
serializedDatabase
;
}
catch
(
error
)
{
this
.
onError
(
error
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录