Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
08e29d24
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,发现更多精彩内容 >>
提交
08e29d24
编写于
12月 08, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove duplicate (case sensitive) recent workspace/folder names on the welcome screen (fix #111954)
上级
bb480d2c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
32 deletion
+33
-32
src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts
.../workspaces/electron-main/workspacesHistoryMainService.ts
+33
-32
未找到文件。
src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts
浏览文件 @
08e29d24
...
...
@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
IStateService
}
from
'
vs/platform/state/node/state
'
;
import
{
app
,
JumpListCategory
}
from
'
electron
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
...
...
@@ -14,7 +14,7 @@ import { isWindows, isMacintosh } from 'vs/base/common/platform';
import
{
IWorkspaceIdentifier
,
ISingleFolderWorkspaceIdentifier
,
isSingleFolderWorkspaceIdentifier
,
IRecentlyOpened
,
isRecentWorkspace
,
isRecentFolder
,
IRecent
,
isRecentFile
,
IRecentFolder
,
IRecentWorkspace
,
IRecentFile
,
toStoreData
,
restoreRecentlyOpened
,
RecentlyOpenedStorageData
,
WORKSPACE_EXTENSION
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IWorkspacesMainService
}
from
'
vs/platform/workspaces/electron-main/workspacesMainService
'
;
import
{
ThrottledDelayer
}
from
'
vs/base/common/async
'
;
import
{
isEqual
,
dirname
,
originalFSPath
,
basename
,
extUriBiasedIgnorePathCase
}
from
'
vs/base/common/resources
'
;
import
{
dirname
,
originalFSPath
,
basename
,
extUriBiasedIgnorePathCase
}
from
'
vs/base/common/resources
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IEnvironmentMainService
}
from
'
vs/platform/environment/electron-main/environmentMainService
'
;
...
...
@@ -57,10 +57,10 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
declare
readonly
_serviceBrand
:
undefined
;
private
readonly
_onRecentlyOpenedChange
=
new
Emitter
<
void
>
(
);
private
readonly
_onRecentlyOpenedChange
=
this
.
_register
(
new
Emitter
<
void
>
()
);
readonly
onRecentlyOpenedChange
:
CommonEvent
<
void
>
=
this
.
_onRecentlyOpenedChange
.
event
;
private
macOSRecentDocumentsUpdater
=
this
.
_register
(
new
ThrottledDelayer
<
void
>
(
800
));
private
readonly
macOSRecentDocumentsUpdater
=
this
.
_register
(
new
ThrottledDelayer
<
void
>
(
800
));
constructor
(
@
IStateService
private
readonly
stateService
:
IStateService
,
...
...
@@ -89,40 +89,40 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
}
this
.
updateWindowsJumpList
();
this
.
onRecentlyOpenedChange
(()
=>
this
.
updateWindowsJumpList
(
));
this
.
_register
(
this
.
onRecentlyOpenedChange
(()
=>
this
.
updateWindowsJumpList
()
));
}
addRecentlyOpened
(
newlyAdde
d
:
IRecent
[]):
void
{
addRecentlyOpened
(
recentToAd
d
:
IRecent
[]):
void
{
const
workspaces
:
Array
<
IRecentFolder
|
IRecentWorkspace
>
=
[];
const
files
:
IRecentFile
[]
=
[];
for
(
let
curr
of
newlyAdde
d
)
{
for
(
let
recent
of
recentToAd
d
)
{
// Workspace
if
(
isRecentWorkspace
(
curr
))
{
if
(
!
this
.
workspacesMainService
.
isUntitledWorkspace
(
curr
.
workspace
)
&&
indexOfWorkspace
(
workspaces
,
curr
.
workspace
)
===
-
1
)
{
workspaces
.
push
(
curr
);
if
(
isRecentWorkspace
(
recent
))
{
if
(
!
this
.
workspacesMainService
.
isUntitledWorkspace
(
recent
.
workspace
)
&&
indexOfWorkspace
(
workspaces
,
recent
.
workspace
)
===
-
1
)
{
workspaces
.
push
(
recent
);
}
}
// Folder
else
if
(
isRecentFolder
(
curr
))
{
if
(
indexOfFolder
(
workspaces
,
curr
.
folderUri
)
===
-
1
)
{
workspaces
.
push
(
curr
);
else
if
(
isRecentFolder
(
recent
))
{
if
(
indexOfFolder
(
workspaces
,
recent
.
folderUri
)
===
-
1
)
{
workspaces
.
push
(
recent
);
}
}
// File
else
{
const
alreadyExistsInHistory
=
indexOfFile
(
files
,
curr
.
fileUri
)
>=
0
;
const
shouldBeFiltered
=
curr
.
fileUri
.
scheme
===
Schemas
.
file
&&
WorkspacesHistoryMainService
.
COMMON_FILES_FILTER
.
indexOf
(
basename
(
curr
.
fileUri
))
>=
0
;
const
alreadyExistsInHistory
=
indexOfFile
(
files
,
recent
.
fileUri
)
>=
0
;
const
shouldBeFiltered
=
recent
.
fileUri
.
scheme
===
Schemas
.
file
&&
WorkspacesHistoryMainService
.
COMMON_FILES_FILTER
.
indexOf
(
basename
(
recent
.
fileUri
))
>=
0
;
if
(
!
alreadyExistsInHistory
&&
!
shouldBeFiltered
)
{
files
.
push
(
curr
);
files
.
push
(
recent
);
// Add to recent documents (Windows only, macOS later)
if
(
isWindows
&&
curr
.
fileUri
.
scheme
===
Schemas
.
file
)
{
app
.
addRecentDocument
(
curr
.
fileUri
.
fsPath
);
if
(
isWindows
&&
recent
.
fileUri
.
scheme
===
Schemas
.
file
)
{
app
.
addRecentDocument
(
recent
.
fileUri
.
fsPath
);
}
}
}
...
...
@@ -147,14 +147,15 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
}
}
removeRecentlyOpened
(
t
oRemove
:
URI
[]):
void
{
removeRecentlyOpened
(
recentT
oRemove
:
URI
[]):
void
{
const
keep
=
(
recent
:
IRecent
)
=>
{
const
uri
=
location
(
recent
);
for
(
const
resource
of
t
oRemove
)
{
if
(
isEqual
(
resourc
e
,
uri
))
{
for
(
const
resource
ToRemove
of
recentT
oRemove
)
{
if
(
extUriBiasedIgnorePathCase
.
isEqual
(
resourceToRemov
e
,
uri
))
{
return
false
;
}
}
return
true
;
};
...
...
@@ -319,8 +320,8 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
items
:
[
{
type
:
'
task
'
,
title
:
nls
.
localize
(
'
newWindow
'
,
"
New Window
"
),
description
:
nls
.
localize
(
'
newWindowDesc
'
,
"
Opens a new window
"
),
title
:
localize
(
'
newWindow
'
,
"
New Window
"
),
description
:
localize
(
'
newWindowDesc
'
,
"
Opens a new window
"
),
program
:
process
.
execPath
,
args
:
'
-n
'
,
// force new window
iconPath
:
process
.
execPath
,
...
...
@@ -351,18 +352,18 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
// Add entries
jumpList
.
push
({
type
:
'
custom
'
,
name
:
nls
.
localize
(
'
recentFolders
'
,
"
Recent Workspaces
"
),
items
:
arrays
.
coalesce
(
this
.
getRecentlyOpened
().
workspaces
.
slice
(
0
,
7
/* limit number of entries here */
).
map
(
recent
=>
{
name
:
localize
(
'
recentFolders
'
,
"
Recent Workspaces
"
),
items
:
coalesce
(
this
.
getRecentlyOpened
().
workspaces
.
slice
(
0
,
7
/* limit number of entries here */
).
map
(
recent
=>
{
const
workspace
=
isRecentWorkspace
(
recent
)
?
recent
.
workspace
:
recent
.
folderUri
;
const
title
=
recent
.
label
?
splitName
(
recent
.
label
).
name
:
this
.
getSimpleWorkspaceLabel
(
workspace
,
this
.
environmentService
.
untitledWorkspacesHome
);
let
description
;
let
args
;
if
(
isSingleFolderWorkspaceIdentifier
(
workspace
))
{
description
=
nls
.
localize
(
'
folderDesc
'
,
"
{0} {1}
"
,
getBaseLabel
(
workspace
),
getPathLabel
(
dirname
(
workspace
),
this
.
environmentService
));
description
=
localize
(
'
folderDesc
'
,
"
{0} {1}
"
,
getBaseLabel
(
workspace
),
getPathLabel
(
dirname
(
workspace
),
this
.
environmentService
));
args
=
`--folder-uri "
${
workspace
.
toString
()}
"`
;
}
else
{
description
=
nls
.
localize
(
'
workspaceDesc
'
,
"
{0} {1}
"
,
getBaseLabel
(
workspace
.
configPath
),
getPathLabel
(
dirname
(
workspace
.
configPath
),
this
.
environmentService
));
description
=
localize
(
'
workspaceDesc
'
,
"
{0} {1}
"
,
getBaseLabel
(
workspace
.
configPath
),
getPathLabel
(
dirname
(
workspace
.
configPath
),
this
.
environmentService
));
args
=
`--file-uri "
${
workspace
.
configPath
.
toString
()}
"`
;
}
...
...
@@ -398,7 +399,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
// Workspace: Untitled
if
(
extUriBiasedIgnorePathCase
.
isEqualOrParent
(
workspace
.
configPath
,
workspaceHome
))
{
return
nls
.
localize
(
'
untitledWorkspace
'
,
"
Untitled (Workspace)
"
);
return
localize
(
'
untitledWorkspace
'
,
"
Untitled (Workspace)
"
);
}
let
filename
=
basename
(
workspace
.
configPath
);
...
...
@@ -406,7 +407,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
filename
=
filename
.
substr
(
0
,
filename
.
length
-
WORKSPACE_EXTENSION
.
length
-
1
);
}
return
nls
.
localize
(
'
workspaceName
'
,
"
{0} (Workspace)
"
,
filename
);
return
localize
(
'
workspaceName
'
,
"
{0} (Workspace)
"
,
filename
);
}
}
...
...
@@ -427,9 +428,9 @@ function indexOfWorkspace(arr: IRecent[], candidate: IWorkspaceIdentifier): numb
}
function
indexOfFolder
(
arr
:
IRecent
[],
candidate
:
ISingleFolderWorkspaceIdentifier
):
number
{
return
arr
.
findIndex
(
folder
=>
isRecentFolder
(
folder
)
&&
isEqual
(
folder
.
folderUri
,
candidate
));
return
arr
.
findIndex
(
folder
=>
isRecentFolder
(
folder
)
&&
extUriBiasedIgnorePathCase
.
isEqual
(
folder
.
folderUri
,
candidate
));
}
function
indexOfFile
(
arr
:
IRecentFile
[],
candidate
:
URI
):
number
{
return
arr
.
findIndex
(
file
=>
isEqual
(
file
.
fileUri
,
candidate
));
return
arr
.
findIndex
(
file
=>
extUriBiasedIgnorePathCase
.
isEqual
(
file
.
fileUri
,
candidate
));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录