Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8bd339f1
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,体验更适合开发者的 AI 搜索 >>
提交
8bd339f1
编写于
6月 09, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💄
上级
7a9a71c7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
31 deletion
+45
-31
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+36
-27
src/vs/platform/history/electron-main/historyMainService.ts
src/vs/platform/history/electron-main/historyMainService.ts
+9
-4
未找到文件。
src/vs/code/electron-main/windows.ts
浏览文件 @
8bd339f1
...
...
@@ -14,7 +14,7 @@ import { IBackupMainService } from 'vs/platform/backup/common/backup';
import
{
IEnvironmentService
,
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/node/storage
'
;
import
{
CodeWindow
,
IWindowState
as
ISingleWindowState
,
defaultWindowState
,
WindowMode
}
from
'
vs/code/electron-main/window
'
;
import
{
ipcMain
as
ipc
,
app
,
screen
,
BrowserWindow
,
dialog
}
from
'
electron
'
;
import
{
ipcMain
as
ipc
,
screen
,
BrowserWindow
,
dialog
}
from
'
electron
'
;
import
{
IPathWithLineAndColumn
,
parseLineAndColumnAware
}
from
'
vs/code/node/paths
'
;
import
{
ILifecycleService
,
UnloadReason
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMain
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -231,15 +231,15 @@ export class WindowsManager implements IWindowsMainService {
let
foldersToRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
)
?
this
.
backupService
.
getWorkspaceBackupPaths
()
:
[];
let
filesToOpen
:
IPath
[]
=
[];
let
filesToDiff
:
IPath
[]
=
[];
let
filesToCreate
=
pathsToOpen
.
filter
(
iPath
=>
!!
iPath
.
filePath
&&
iPath
.
createFilePath
);
let
emptyToOpen
=
pathsToOpen
.
filter
(
iPath
=>
!
iPath
.
workspacePath
&&
!
iPath
.
filePath
);
let
emptyToRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
)
?
this
.
backupService
.
getEmptyWorkspaceBackupPaths
()
:
[];
let
filesToCreate
=
pathsToOpen
.
filter
(
iPath
=>
!!
iPath
.
filePath
&&
iPath
.
createFilePath
);
// Diff mode needs special care
const
c
andidates
=
pathsToOpen
.
filter
(
iPath
=>
!!
iPath
.
filePath
&&
!
iPath
.
createFilePath
);
const
filesToOpenC
andidates
=
pathsToOpen
.
filter
(
iPath
=>
!!
iPath
.
filePath
&&
!
iPath
.
createFilePath
);
if
(
openConfig
.
diffMode
)
{
if
(
c
andidates
.
length
===
2
)
{
filesToDiff
=
c
andidates
;
if
(
filesToOpenC
andidates
.
length
===
2
)
{
filesToDiff
=
filesToOpenC
andidates
;
}
else
{
emptyToOpen
=
[
Object
.
create
(
null
)];
// improper use of diffMode, open empty
}
...
...
@@ -248,34 +248,16 @@ export class WindowsManager implements IWindowsMainService {
foldersToRestore
=
[];
// diff is always in empty workspace
filesToCreate
=
[];
// diff ignores other files that do not exist
}
else
{
filesToOpen
=
c
andidates
;
filesToOpen
=
filesToOpenC
andidates
;
}
// let the user settings override how folders are open in a new window or same window unless we are forced
const
windowConfig
=
this
.
configurationService
.
getConfiguration
<
IWindowSettings
>
(
'
window
'
);
let
openFolderInNewWindow
=
(
openConfig
.
preferNewWindow
||
openConfig
.
forceNewWindow
)
&&
!
openConfig
.
forceReuseWindow
;
if
(
!
openConfig
.
forceNewWindow
&&
!
openConfig
.
forceReuseWindow
&&
windowConfig
&&
(
windowConfig
.
openFoldersInNewWindow
===
'
on
'
||
windowConfig
.
openFoldersInNewWindow
===
'
off
'
))
{
openFolderInNewWindow
=
(
windowConfig
.
openFoldersInNewWindow
===
'
on
'
);
}
// Settings can decide if files/folders open in new window or not
let
{
openFolderInNewWindow
,
openFilesInNewWindow
}
=
this
.
shouldOpenNewWindow
(
openConfig
);
// Handle files to open/diff or to create when we dont open a folder and we do not restore any folder/untitled from hot-exit
const
usedWindows
:
CodeWindow
[]
=
[];
if
(
!
foldersToOpen
.
length
&&
!
foldersToRestore
.
length
&&
!
emptyToRestore
.
length
&&
(
filesToOpen
.
length
>
0
||
filesToCreate
.
length
>
0
||
filesToDiff
.
length
>
0
))
{
// let the user settings override how files are open in a new window or same window unless we are forced (not for extension development though)
let
openFilesInNewWindow
:
boolean
;
if
(
openConfig
.
forceNewWindow
||
openConfig
.
forceReuseWindow
)
{
openFilesInNewWindow
=
openConfig
.
forceNewWindow
&&
!
openConfig
.
forceReuseWindow
;
}
else
{
if
(
openConfig
.
context
===
OpenContext
.
DOCK
)
{
openFilesInNewWindow
=
true
;
// only on macOS do we allow to open files in a new window if this is triggered via DOCK context
}
if
(
!
openConfig
.
cli
.
extensionDevelopmentPath
&&
windowConfig
&&
(
windowConfig
.
openFilesInNewWindow
===
'
on
'
||
windowConfig
.
openFilesInNewWindow
===
'
off
'
))
{
openFilesInNewWindow
=
(
windowConfig
.
openFilesInNewWindow
===
'
on
'
);
}
}
// Open Files in last instance if any and flag tells us so
const
fileToCheck
=
filesToOpen
[
0
]
||
filesToCreate
[
0
]
||
filesToDiff
[
0
];
const
windowOrFolder
=
findBestWindowOrFolder
({
...
...
@@ -286,6 +268,7 @@ export class WindowsManager implements IWindowsMainService {
filePath
:
fileToCheck
&&
fileToCheck
.
filePath
,
userHome
:
this
.
environmentService
.
userHome
});
if
(
windowOrFolder
instanceof
CodeWindow
)
{
windowOrFolder
.
focus
();
const
files
=
{
filesToOpen
,
filesToCreate
,
filesToDiff
};
// copy to object because they get reset shortly after
...
...
@@ -328,6 +311,7 @@ export class WindowsManager implements IWindowsMainService {
if
(
windowsOnWorkspacePath
.
length
>
0
)
{
const
browserWindow
=
windowsOnWorkspacePath
[
0
];
browserWindow
.
focus
();
// just focus one of them
const
files
=
{
filesToOpen
,
filesToCreate
,
filesToDiff
};
// copy to object because they get reset shortly after
browserWindow
.
ready
().
then
(
readyWindow
=>
{
readyWindow
.
send
(
'
vscode:openFiles
'
,
files
);
...
...
@@ -418,7 +402,6 @@ export class WindowsManager implements IWindowsMainService {
pathsToOpen
.
forEach
(
iPath
=>
{
if
(
iPath
.
filePath
||
iPath
.
workspacePath
)
{
app
.
addRecentDocument
(
iPath
.
filePath
||
iPath
.
workspacePath
);
recentPaths
.
push
({
path
:
iPath
.
filePath
||
iPath
.
workspacePath
,
isFile
:
!!
iPath
.
filePath
});
}
});
...
...
@@ -576,6 +559,32 @@ export class WindowsManager implements IWindowsMainService {
return
null
;
}
private
shouldOpenNewWindow
(
openConfig
:
IOpenConfiguration
):
{
openFolderInNewWindow
:
boolean
;
openFilesInNewWindow
:
boolean
;
}
{
// let the user settings override how folders are open in a new window or same window unless we are forced
const
windowConfig
=
this
.
configurationService
.
getConfiguration
<
IWindowSettings
>
(
'
window
'
);
let
openFolderInNewWindow
=
(
openConfig
.
preferNewWindow
||
openConfig
.
forceNewWindow
)
&&
!
openConfig
.
forceReuseWindow
;
if
(
!
openConfig
.
forceNewWindow
&&
!
openConfig
.
forceReuseWindow
&&
windowConfig
&&
(
windowConfig
.
openFoldersInNewWindow
===
'
on
'
||
windowConfig
.
openFoldersInNewWindow
===
'
off
'
))
{
openFolderInNewWindow
=
(
windowConfig
.
openFoldersInNewWindow
===
'
on
'
);
}
// let the user settings override how files are open in a new window or same window unless we are forced (not for extension development though)
let
openFilesInNewWindow
:
boolean
;
if
(
openConfig
.
forceNewWindow
||
openConfig
.
forceReuseWindow
)
{
openFilesInNewWindow
=
openConfig
.
forceNewWindow
&&
!
openConfig
.
forceReuseWindow
;
}
else
{
if
(
openConfig
.
context
===
OpenContext
.
DOCK
)
{
openFilesInNewWindow
=
true
;
// only on macOS do we allow to open files in a new window if this is triggered via DOCK context
}
if
(
!
openConfig
.
cli
.
extensionDevelopmentPath
&&
windowConfig
&&
(
windowConfig
.
openFilesInNewWindow
===
'
on
'
||
windowConfig
.
openFilesInNewWindow
===
'
off
'
))
{
openFilesInNewWindow
=
(
windowConfig
.
openFilesInNewWindow
===
'
on
'
);
}
}
return
{
openFolderInNewWindow
,
openFilesInNewWindow
};
}
public
openExtensionDevelopmentHostWindow
(
openConfig
:
IOpenConfiguration
):
void
{
// Reload an existing extension development host window on the same path
...
...
src/vs/platform/history/electron-main/historyMainService.ts
浏览文件 @
8bd339f1
...
...
@@ -6,7 +6,6 @@
'
use strict
'
;
import
*
as
path
from
'
path
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
trim
}
from
'
vs/base/common/strings
'
;
...
...
@@ -17,6 +16,7 @@ import { getPathLabel } from 'vs/base/common/labels';
import
{
IPath
}
from
'
vs/platform/windows/common/windows
'
;
import
CommonEvent
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
createDecorator
}
from
"
vs/platform/instantiation/common/instantiation
"
;
import
{
isWindows
,
isMacintosh
,
isLinux
}
from
"
vs/base/common/platform
"
;
export
const
IHistoryMainService
=
createDecorator
<
IHistoryMainService
>
(
'
historyMainService
'
);
...
...
@@ -69,15 +69,20 @@ export class HistoryMainService implements IHistoryMainService {
if
(
isFile
)
{
mru
.
files
.
unshift
(
path
);
mru
.
files
=
arrays
.
distinct
(
mru
.
files
,
(
f
)
=>
platform
.
isLinux
?
f
:
f
.
toLowerCase
());
mru
.
files
=
arrays
.
distinct
(
mru
.
files
,
(
f
)
=>
isLinux
?
f
:
f
.
toLowerCase
());
}
else
{
mru
.
folders
.
unshift
(
path
);
mru
.
folders
=
arrays
.
distinct
(
mru
.
folders
,
(
f
)
=>
platform
.
isLinux
?
f
:
f
.
toLowerCase
());
mru
.
folders
=
arrays
.
distinct
(
mru
.
folders
,
(
f
)
=>
isLinux
?
f
:
f
.
toLowerCase
());
}
// Make sure its bounded
mru
.
folders
=
mru
.
folders
.
slice
(
0
,
HistoryMainService
.
MAX_TOTAL_RECENT_ENTRIES
);
mru
.
files
=
mru
.
files
.
slice
(
0
,
HistoryMainService
.
MAX_TOTAL_RECENT_ENTRIES
);
// Add to recent documents (Windows/macOS only)
if
(
isMacintosh
||
isWindows
)
{
app
.
addRecentDocument
(
path
);
}
});
this
.
storageService
.
setItem
(
HistoryMainService
.
recentPathsListStorageKey
,
mru
);
...
...
@@ -157,7 +162,7 @@ export class HistoryMainService implements IHistoryMainService {
}
public
updateWindowsJumpList
():
void
{
if
(
!
platform
.
isWindows
)
{
if
(
!
isWindows
)
{
return
;
// only on windows
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录