Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
87846655
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,发现更多精彩内容 >>
提交
87846655
编写于
8月 15, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
do not resolve siblings unless needed (for #9962)
上级
d0836bbb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
18 deletion
+31
-18
src/vs/base/common/glob.ts
src/vs/base/common/glob.ts
+18
-4
src/vs/base/test/common/glob.test.ts
src/vs/base/test/common/glob.test.ts
+10
-10
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
+2
-3
src/vs/workbench/services/search/node/fileSearch.ts
src/vs/workbench/services/search/node/fileSearch.ts
+1
-1
未找到文件。
src/vs/base/common/glob.ts
浏览文件 @
87846655
...
...
@@ -281,8 +281,8 @@ function toRegExp(regEx: string): RegExp {
* - character ranges (using [...])
*/
export
function
match
(
pattern
:
string
,
path
:
string
):
boolean
;
export
function
match
(
expression
:
IExpression
,
path
:
string
,
siblings
?:
string
[]):
string
/* the matching pattern */
;
export
function
match
(
arg1
:
string
|
IExpression
,
path
:
string
,
siblings
?:
string
[]):
any
{
export
function
match
(
expression
:
IExpression
,
path
:
string
,
siblings
Fn
?:
()
=>
string
[]):
string
/* the matching pattern */
;
export
function
match
(
arg1
:
string
|
IExpression
,
path
:
string
,
siblings
Fn
?:
()
=>
string
[]):
any
{
if
(
!
arg1
||
!
path
)
{
return
false
;
}
...
...
@@ -315,10 +315,13 @@ export function match(arg1: string | IExpression, path: string, siblings?: strin
}
// Glob with Expression
return
matchExpression
(
<
IExpression
>
arg1
,
path
,
siblings
);
return
matchExpression
(
<
IExpression
>
arg1
,
path
,
siblings
Fn
);
}
function
matchExpression
(
expression
:
IExpression
,
path
:
string
,
siblings
?:
string
[]):
string
/* the matching pattern */
{
function
matchExpression
(
expression
:
IExpression
,
path
:
string
,
siblingsFn
?:
()
=>
string
[]):
string
/* the matching pattern */
{
let
siblings
:
string
[];
let
siblingsResolved
=
false
;
let
patterns
=
Object
.
getOwnPropertyNames
(
expression
);
let
basename
:
string
;
for
(
let
i
=
0
;
i
<
patterns
.
length
;
i
++
)
{
...
...
@@ -339,6 +342,17 @@ function matchExpression(expression: IExpression, path: string, siblings?: strin
// Expression Pattern is <SiblingClause>
if
(
value
&&
typeof
(
<
SiblingClause
>
value
).
when
===
'
string
'
)
{
// Resolve siblings only once
if
(
!
siblingsResolved
)
{
siblingsResolved
=
true
;
if
(
siblingsFn
)
{
siblings
=
siblingsFn
();
}
else
{
siblings
=
[];
}
}
if
(
!
siblings
||
!
siblings
.
length
)
{
continue
;
// pattern is malformed or we don't have siblings
}
...
...
src/vs/base/test/common/glob.test.ts
浏览文件 @
87846655
...
...
@@ -401,9 +401,9 @@ suite('Glob', () => {
}
};
assert
.
equal
(
'
**/*.js
'
,
glob
.
match
(
expression
,
'
test.js
'
,
siblings
));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
[]));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
[
'
te.ts
'
]));
assert
.
equal
(
'
**/*.js
'
,
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
siblings
));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
[]));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
[
'
te.ts
'
]));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
));
expression
=
{
...
...
@@ -412,18 +412,18 @@ suite('Glob', () => {
}
};
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
siblings
));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
siblings
));
expression
=
<
any
>
{
'
**/*.js
'
:
{
}
};
assert
.
equal
(
'
**/*.js
'
,
glob
.
match
(
expression
,
'
test.js
'
,
siblings
));
assert
.
equal
(
'
**/*.js
'
,
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
siblings
));
expression
=
{};
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
siblings
));
assert
(
!
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
siblings
));
});
test
(
'
expression support (multiple)
'
,
function
()
{
...
...
@@ -437,11 +437,11 @@ suite('Glob', () => {
'
**/*.bananas
'
:
{
bananas
:
true
}
};
assert
.
equal
(
'
**/*.js
'
,
glob
.
match
(
expression
,
'
test.js
'
,
siblings
));
assert
.
equal
(
'
**/*.as
'
,
glob
.
match
(
expression
,
'
test.as
'
,
siblings
));
assert
.
equal
(
'
**/*.bananas
'
,
glob
.
match
(
expression
,
'
test.bananas
'
,
siblings
));
assert
.
equal
(
'
**/*.js
'
,
glob
.
match
(
expression
,
'
test.js
'
,
()
=>
siblings
));
assert
.
equal
(
'
**/*.as
'
,
glob
.
match
(
expression
,
'
test.as
'
,
()
=>
siblings
));
assert
.
equal
(
'
**/*.bananas
'
,
glob
.
match
(
expression
,
'
test.bananas
'
,
()
=>
siblings
));
assert
.
equal
(
'
**/*.bananas
'
,
glob
.
match
(
expression
,
'
test.bananas
'
));
assert
(
!
glob
.
match
(
expression
,
'
test.foo
'
,
siblings
));
assert
(
!
glob
.
match
(
expression
,
'
test.foo
'
,
()
=>
siblings
));
});
test
(
'
brackets
'
,
function
()
{
...
...
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
浏览文件 @
87846655
...
...
@@ -682,10 +682,9 @@ export class FileFilter implements IFilter {
return
true
;
// always visible
}
let
siblings
=
stat
.
parent
&&
stat
.
parent
.
children
&&
stat
.
parent
.
children
.
map
(
c
=>
c
.
name
);
// Hide those that match Hidden Patterns
if
(
glob
.
match
(
this
.
hiddenExpression
,
this
.
contextService
.
toWorkspaceRelativePath
(
stat
.
resource
),
siblings
))
{
const
siblingsFn
=
()
=>
stat
.
parent
&&
stat
.
parent
.
children
&&
stat
.
parent
.
children
.
map
(
c
=>
c
.
name
);
if
(
glob
.
match
(
this
.
hiddenExpression
,
this
.
contextService
.
toWorkspaceRelativePath
(
stat
.
resource
),
siblingsFn
))
{
return
false
;
// hidden through pattern
}
...
...
src/vs/workbench/services/search/node/fileSearch.ts
浏览文件 @
87846655
...
...
@@ -181,7 +181,7 @@ export class FileWalker {
// Check exclude pattern
let
currentRelativePathWithSlashes
=
relativeParentPathWithSlashes
?
[
relativeParentPathWithSlashes
,
file
].
join
(
'
/
'
)
:
file
;
if
(
glob
.
match
(
this
.
excludePattern
,
currentRelativePathWithSlashes
,
siblings
))
{
if
(
glob
.
match
(
this
.
excludePattern
,
currentRelativePathWithSlashes
,
()
=>
siblings
))
{
return
clb
(
null
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录