Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ca9944ae
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 搜索 >>
提交
ca9944ae
编写于
7月 10, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reuse code to open files in a specific folder
上级
3709275a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
17 deletion
+33
-17
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+33
-17
未找到文件。
src/vs/code/electron-main/windows.ts
浏览文件 @
ca9944ae
...
...
@@ -31,7 +31,6 @@ import { IHistoryMainService } from "vs/platform/history/electron-main/historyMa
import
{
IProcessEnvironment
,
isLinux
,
isMacintosh
,
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
TPromise
}
from
"
vs/base/common/winjs.base
"
;
enum
WindowError
{
UNRESPONSIVE
,
CRASHED
...
...
@@ -285,7 +284,6 @@ export class WindowsManager implements IWindowsMainService {
// These are windows to open to show either folders or files (including diffing files or creating them)
//
const
foldersToOpen
=
arrays
.
distinct
(
windowsToOpen
.
filter
(
win
=>
win
.
folderPath
&&
!
win
.
filePath
).
map
(
win
=>
win
.
folderPath
),
folder
=>
isLinux
?
folder
:
folder
.
toLowerCase
());
// prevent duplicates
const
emptyToOpen
=
windowsToOpen
.
filter
(
win
=>
!
win
.
folderPath
&&
!
win
.
filePath
&&
!
win
.
backupPath
).
length
;
let
filesToOpen
=
windowsToOpen
.
filter
(
path
=>
!!
path
.
filePath
&&
!
path
.
createFilePath
);
let
filesToCreate
=
windowsToOpen
.
filter
(
path
=>
!!
path
.
filePath
&&
path
.
createFilePath
);
...
...
@@ -299,7 +297,7 @@ export class WindowsManager implements IWindowsMainService {
}
//
// These are windows to restore because of hot-exit
// These are windows to restore because of hot-exit
or empty windows from previous session
//
const
hotExitRestore
=
(
openConfig
.
initialStartup
&&
!
openConfig
.
cli
.
extensionDevelopmentPath
);
const
foldersToRestore
=
hotExitRestore
?
this
.
backupService
.
getWorkspaceBackupPaths
()
:
[];
...
...
@@ -307,6 +305,11 @@ export class WindowsManager implements IWindowsMainService {
emptyToRestore
.
push
(...
windowsToOpen
.
filter
(
w
=>
!
w
.
folderPath
&&
w
.
backupPath
).
map
(
w
=>
path
.
basename
(
w
.
backupPath
)));
// add empty windows with backupPath
emptyToRestore
=
arrays
.
distinct
(
emptyToRestore
);
// prevent duplicates
//
// These are empty windows to open
//
const
emptyToOpen
=
windowsToOpen
.
filter
(
win
=>
!
win
.
folderPath
&&
!
win
.
filePath
&&
!
win
.
backupPath
).
length
;
// Open based on config
const
usedWindows
=
this
.
doOpen
(
openConfig
,
foldersToOpen
,
foldersToRestore
,
emptyToRestore
,
emptyToOpen
,
filesToOpen
,
filesToCreate
,
filesToDiff
);
...
...
@@ -378,7 +381,7 @@ export class WindowsManager implements IWindowsMainService {
userHome
:
this
.
environmentService
.
userHome
});
// We found a suitable window to open the files within
// We found a suitable window to open the files within
: send the files to open over
if
(
bestWindowOrFolder
instanceof
CodeWindow
)
{
const
files
=
{
filesToOpen
,
filesToCreate
,
filesToDiff
};
// copy to object because they get reset shortly after
...
...
@@ -389,16 +392,24 @@ export class WindowsManager implements IWindowsMainService {
});
usedWindows
.
push
(
windowToUse
);
// Reset these because we handled them
filesToOpen
=
[];
filesToCreate
=
[];
filesToDiff
=
[];
}
// We found a suitable folder to open: add it to foldersToOpen
else
if
(
typeof
bestWindowOrFolder
===
'
string
'
)
{
foldersToOpen
.
push
(
bestWindowOrFolder
);
}
//
Otherwise open a new window with the best folder to use for the file
//
Finally, if no window or folder is found, just open the files in an empty window
else
{
const
folderToOpen
=
bestWindowOrFolder
;
const
browserWindow
=
this
.
openInBrowserWindow
({
userEnv
:
openConfig
.
userEnv
,
cli
:
openConfig
.
cli
,
initialStartup
:
openConfig
.
initialStartup
,
folderPath
:
folderToOpen
,
filesToOpen
,
filesToCreate
,
filesToDiff
,
...
...
@@ -406,13 +417,11 @@ export class WindowsManager implements IWindowsMainService {
});
usedWindows
.
push
(
browserWindow
);
openFolderInNewWindow
=
true
;
// any other folders to open must open in new window then
// Reset these because we handled them
filesToOpen
=
[];
filesToCreate
=
[];
filesToDiff
=
[];
}
// Reset these because we handled them
filesToOpen
=
[];
filesToCreate
=
[];
filesToDiff
=
[];
}
// Handle folders to open (instructed and to restore)
...
...
@@ -680,13 +689,20 @@ export class WindowsManager implements IWindowsMainService {
try
{
const
candidateStat
=
fs
.
statSync
(
candidate
);
if
(
candidateStat
)
{
return
candidateStat
.
isFile
()
?
{
// File
if
(
candidateStat
.
isFile
())
{
return
{
filePath
:
candidate
,
lineNumber
:
gotoLineMode
?
parsedPath
.
line
:
void
0
,
columnNumber
:
gotoLineMode
?
parsedPath
.
column
:
void
0
}
:
{
folderPath
:
candidate
};
};
}
// Folder
return
{
folderPath
:
candidate
};
}
}
catch
(
error
)
{
this
.
historyService
.
removeFromRecentPathsList
(
candidate
);
// since file does not seem to exist anymore, remove from recent
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录