Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3c764acd
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,发现更多精彩内容 >>
提交
3c764acd
编写于
6月 23, 2017
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make "find in folder" multiroot aware
上级
d760b6fc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
98 addition
and
23 deletion
+98
-23
src/vs/base/common/paths.ts
src/vs/base/common/paths.ts
+34
-0
src/vs/base/test/common/paths.test.ts
src/vs/base/test/common/paths.test.ts
+50
-0
src/vs/workbench/parts/search/browser/patternInputWidget.ts
src/vs/workbench/parts/search/browser/patternInputWidget.ts
+8
-13
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+3
-1
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+3
-9
未找到文件。
src/vs/base/common/paths.ts
浏览文件 @
3c764acd
...
...
@@ -393,3 +393,37 @@ export function isEqualOrParent(path: string, candidate: string, ignoreCase?: bo
return
path
.
indexOf
(
candidate
)
===
0
;
}
/**
* Adapted from Node's path.isAbsolute functions
* @param path
*/
export
function
isAbsolute
(
path
:
string
):
boolean
{
return
isWindows
?
isAbsolute_win32
(
path
)
:
isAbsolute_posix
(
path
);
}
export
function
isAbsolute_win32
(
path
:
string
):
boolean
{
if
(
!
path
)
{
return
false
;
}
const
char0
=
path
.
charCodeAt
(
0
);
if
(
char0
===
CharCode
.
Slash
||
char0
===
CharCode
.
Backslash
)
{
return
true
;
}
else
if
((
char0
>=
CharCode
.
A
&&
char0
<=
CharCode
.
Z
)
||
(
char0
>=
CharCode
.
a
&&
char0
<=
CharCode
.
z
))
{
if
(
path
.
length
>
2
&&
path
.
charCodeAt
(
1
)
===
CharCode
.
Colon
)
{
const
char2
=
path
.
charCodeAt
(
2
);
if
(
char2
===
CharCode
.
Slash
||
char0
===
CharCode
.
Backslash
)
{
return
true
;
}
}
}
return
false
;
}
export
function
isAbsolute_posix
(
path
:
string
):
boolean
{
return
path
&&
path
.
charCodeAt
(
0
)
===
CharCode
.
Slash
;
}
\ No newline at end of file
src/vs/base/test/common/paths.test.ts
浏览文件 @
3c764acd
...
...
@@ -201,4 +201,54 @@ suite('Paths', () => {
assert
.
ok
(
!
paths
.
isValidBasename
(
'
tes"t.txt
'
));
}
});
test
(
'
isAbsolute_win
'
,
()
=>
{
// Absolute paths
[
'
C:/
'
,
'
C:/foo
'
,
'
z:/foo/bar.txt
'
,
'
\\\\
localhost
\\
c$
\\
foo
'
,
'
/
'
,
'
/foo
'
].
forEach
(
absolutePath
=>
{
assert
.
ok
(
paths
.
isAbsolute_win32
(
absolutePath
),
absolutePath
);
});
// Not absolute paths
[
''
,
'
foo
'
,
'
foo/bar
'
,
'
./foo
'
,
'
http://foo.com/bar
'
].
forEach
(
nonAbsolutePath
=>
{
assert
.
ok
(
!
paths
.
isAbsolute_win32
(
nonAbsolutePath
),
nonAbsolutePath
);
});
});
test
(
'
isAbsolute_posix
'
,
()
=>
{
// Absolute paths
[
'
/
'
,
'
/foo
'
,
'
/foo/bar.txt
'
].
forEach
(
absolutePath
=>
{
assert
.
ok
(
paths
.
isAbsolute_posix
(
absolutePath
),
absolutePath
);
});
// Not absolute paths
[
''
,
'
foo
'
,
'
foo/bar
'
,
'
./foo
'
,
'
http://foo.com/bar
'
,
'
z:/foo/bar.txt
'
,
].
forEach
(
nonAbsolutePath
=>
{
assert
.
ok
(
!
paths
.
isAbsolute_posix
(
nonAbsolutePath
),
nonAbsolutePath
);
});
});
});
\ No newline at end of file
src/vs/workbench/parts/search/browser/patternInputWidget.ts
浏览文件 @
3c764acd
...
...
@@ -6,6 +6,7 @@
import
nls
=
require
(
'
vs/nls
'
);
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
collections
=
require
(
'
vs/base/common/collections
'
);
import
{
$
}
from
'
vs/base/browser/builder
'
;
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
...
...
@@ -122,7 +123,7 @@ export class PatternInputWidget extends Widget {
exprSegments
=
groups
.
exprSegments
;
}
else
{
const
segments
=
pattern
.
split
(
'
,
'
)
.
map
(
s
=>
s
trings
.
trim
(
s
.
trim
(),
'
/
'
))
.
map
(
s
=>
s
.
trim
(
))
.
filter
(
s
=>
!!
s
.
length
);
const
groups
=
this
.
groupByPathsAndExprSegments
(
segments
);
...
...
@@ -142,22 +143,16 @@ export class PatternInputWidget extends Widget {
}
private
groupByPathsAndExprSegments
(
segments
:
string
[])
{
const
isSearchPath
=
segment
=>
segment
.
match
(
/^
\.\/
/
);
const
isSearchPath
=
(
segment
:
string
)
=>
{
// An segment is a search path if it is an absolute path and doesn't contain any glob characters
return
paths
.
isAbsolute
(
segment
)
&&
!
segment
.
match
(
/
[\*\{\}\(\)\[\]\?]
/
);
};
const
groups
=
collections
.
groupBy
(
segments
,
segment
=>
isSearchPath
(
segment
)
?
'
searchPaths
'
:
'
exprSegments
'
);
groups
.
searchPaths
=
groups
.
searchPaths
||
[];
groups
.
exprSegments
=
groups
.
exprSegments
||
[];
// If a ./searchPath has a glob character, remove ./ and use it as an expression segment
groups
.
searchPaths
=
groups
.
searchPaths
.
filter
(
searchPath
=>
{
if
(
searchPath
.
match
(
/
[\*\{\}\(\)\[\]\?]
/
))
{
groups
.
exprSegments
.
push
(
strings
.
ltrim
(
searchPath
,
'
./
'
));
return
false
;
}
return
true
;
});
groups
.
exprSegments
=
(
groups
.
exprSegments
||
[])
.
map
(
segment
=>
strings
.
trim
(
segment
,
'
/
'
));
return
groups
;
}
...
...
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
3c764acd
...
...
@@ -273,7 +273,9 @@ export const findInFolderCommand = (accessor: ServicesAccessor, resource?: URI)
}
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
,
true
).
then
((
viewlet
:
SearchViewlet
)
=>
{
viewlet
.
searchInFolder
(
resource
);
if
(
resource
)
{
viewlet
.
searchInFolder
(
resource
);
}
}).
done
(
null
,
errors
.
onUnexpectedError
);
};
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
3c764acd
...
...
@@ -894,20 +894,14 @@ export class SearchViewlet extends Viewlet {
}
}
public
searchInFolder
(
resource
?:
URI
):
void
{
const
workspaceRelativePath
=
this
.
contextService
.
toWorkspaceRelativePath
(
resource
);
if
(
!
workspaceRelativePath
||
workspaceRelativePath
===
'
.
'
)
{
this
.
inputPatternIncludes
.
setValue
(
''
);
this
.
searchWidget
.
focus
();
return
;
}
public
searchInFolder
(
resource
:
URI
):
void
{
// Show 'files to include' box
if
(
!
this
.
showsFileTypes
())
{
this
.
toggleQueryDetails
(
true
,
true
);
}
this
.
inputPatternIncludes
.
setIsGlobPattern
(
false
);
this
.
inputPatternIncludes
.
setValue
(
'
./
'
+
workspaceRelative
Path
);
this
.
inputPatternIncludes
.
setValue
(
resource
.
fs
Path
);
this
.
searchWidget
.
focus
(
false
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录