Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
69e7247e
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69e7247e
编写于
9月 04, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stop fs.realpath when opening so that symlinks are left intact (fixes #18837)
上级
8c4a4c10
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
24 deletion
+15
-24
src/vs/code/node/paths.ts
src/vs/code/node/paths.ts
+7
-13
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+8
-11
未找到文件。
src/vs/code/node/paths.ts
浏览文件 @
69e7247e
...
...
@@ -12,16 +12,16 @@ import * as paths from 'vs/base/common/paths';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
realpathSync
}
from
'
vs/base/node/extfs
'
;
export
function
validatePaths
(
args
:
ParsedArgs
):
ParsedArgs
{
// Track URLs if they're going to be used
if
(
args
[
'
open-url
'
])
{
args
.
_urls
=
args
.
_
;
args
.
_
=
[];
}
//
Realpath/n
ormalize paths and watch out for goto line mode
//
N
ormalize paths and watch out for goto line mode
const
paths
=
doValidatePaths
(
args
.
_
,
args
.
goto
);
// Update environment
...
...
@@ -46,26 +46,20 @@ function doValidatePaths(args: string[], gotoLineMode?: boolean): string[] {
pathCandidate
=
preparePath
(
cwd
,
pathCandidate
);
}
let
realPath
:
string
;
try
{
realPath
=
realpathSync
(
pathCandidate
);
}
catch
(
error
)
{
// in case of an error, assume the user wants to create this file
// if the path is relative, we join it to the cwd
realPath
=
path
.
normalize
(
path
.
isAbsolute
(
pathCandidate
)
?
pathCandidate
:
path
.
join
(
cwd
,
pathCandidate
));
}
const
absolutePath
=
path
.
normalize
(
path
.
isAbsolute
(
pathCandidate
)
?
pathCandidate
:
path
.
join
(
cwd
,
pathCandidate
));
const
basename
=
path
.
basename
(
real
Path
);
const
basename
=
path
.
basename
(
absolute
Path
);
if
(
basename
/* can be empty if code is opened on root */
&&
!
paths
.
isValidBasename
(
basename
))
{
return
null
;
// do not allow invalid file names
}
if
(
gotoLineMode
)
{
parsedPath
.
path
=
realPath
;
parsedPath
.
path
=
absolutePath
;
return
toPath
(
parsedPath
);
}
return
real
Path
;
return
absolute
Path
;
});
const
caseInsensitive
=
platform
.
isWindows
||
platform
.
isMacintosh
;
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
69e7247e
...
...
@@ -21,7 +21,8 @@ import { IWorkspaceContextService, Workspace, WorkbenchState } from 'vs/platform
import
{
WorkspaceService
}
from
'
vs/workbench/services/configuration/node/configurationService
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
realpath
}
from
'
vs/base/node/pfs
'
;
import
{
stat
}
from
'
vs/base/node/pfs
'
;
import
{
normalize
,
join
,
isAbsolute
}
from
'
path
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
*
as
gracefulFs
from
'
graceful-fs
'
;
import
{
KeyboardMapperFactory
}
from
'
vs/workbench/services/keybinding/electron-browser/keybindingService
'
;
...
...
@@ -147,18 +148,19 @@ function validateFolderUri(folderUri: ISingleFolderWorkspaceIdentifier, verbose:
return
TPromise
.
as
(
folderUri
);
}
// Otherwise: use realpath to resolve symbolic links to the truth
return
realpath
(
folderUri
.
fsPath
).
then
(
realFolderPath
=>
{
// Ensure absolute existing folder path
let
absoluteFolderPath
=
normalize
(
isAbsolute
(
folderUri
.
fsPath
)
?
folderUri
.
fsPath
:
join
(
process
.
env
[
'
VSCODE_CWD
'
]
||
process
.
cwd
(),
folderUri
.
fsPath
));
return
stat
(
absoluteFolderPath
).
then
(
stat
=>
{
// For some weird reason, node adds a trailing slash to UNC paths
// we never ever want trailing slashes as our workspace path unless
// someone opens root ("/").
// See also https://github.com/nodejs/io.js/issues/1765
if
(
paths
.
isUNC
(
realFolderPath
)
&&
strings
.
endsWith
(
real
FolderPath
,
paths
.
nativeSep
))
{
realFolderPath
=
strings
.
rtrim
(
real
FolderPath
,
paths
.
nativeSep
);
if
(
paths
.
isUNC
(
absoluteFolderPath
)
&&
strings
.
endsWith
(
absolute
FolderPath
,
paths
.
nativeSep
))
{
absoluteFolderPath
=
strings
.
rtrim
(
absolute
FolderPath
,
paths
.
nativeSep
);
}
return
uri
.
file
(
real
FolderPath
);
return
uri
.
file
(
absolute
FolderPath
);
},
error
=>
{
if
(
verbose
)
{
errors
.
onUnexpectedError
(
error
);
...
...
@@ -166,11 +168,6 @@ function validateFolderUri(folderUri: ISingleFolderWorkspaceIdentifier, verbose:
// Treat any error case as empty workbench case (no folder path)
return
null
;
}).
then
(
realFolderUriOrNull
=>
{
// Update config with real path if we have one
return
realFolderUriOrNull
;
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录