Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ec4fe07f
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,发现更多精彩内容 >>
提交
ec4fe07f
编写于
3月 19, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - allow relative path matches even if excluded
上级
9f2cc0cc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
75 addition
and
21 deletion
+75
-21
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
...s/workbench/contrib/search/browser/anythingQuickAccess.ts
+75
-21
未找到文件。
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts
浏览文件 @
ec4fe07f
...
@@ -10,7 +10,7 @@ import { prepareQuery, IPreparedQuery, compareItemsByScore, scoreItem, ScorerCac
...
@@ -10,7 +10,7 @@ import { prepareQuery, IPreparedQuery, compareItemsByScore, scoreItem, ScorerCac
import
{
IFileQueryBuilderOptions
,
QueryBuilder
}
from
'
vs/workbench/contrib/search/common/queryBuilder
'
;
import
{
IFileQueryBuilderOptions
,
QueryBuilder
}
from
'
vs/workbench/contrib/search/common/queryBuilder
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
getOutOfWorkspaceEditorResources
,
extractRangeFromFilter
,
IWorkbenchSearchConfiguration
}
from
'
vs/workbench/contrib/search/common/search
'
;
import
{
getOutOfWorkspaceEditorResources
,
extractRangeFromFilter
,
IWorkbenchSearchConfiguration
}
from
'
vs/workbench/contrib/search/common/search
'
;
import
{
ISearchService
,
IFileMatch
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ISearchService
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
untildify
}
from
'
vs/base/common/labels
'
;
import
{
untildify
}
from
'
vs/base/common/labels
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
import
{
IRemotePathService
}
from
'
vs/workbench/services/path/common/remotePathService
'
;
...
@@ -258,7 +258,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
...
@@ -258,7 +258,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
//#region File Search
//#region File Search
private
fileQueryDelayer
=
this
.
_register
(
new
ThrottledDelayer
<
IFileMatch
[]
>
(
AnythingQuickAccessProvider
.
TYPING_SEARCH_DELAY
));
private
fileQueryDelayer
=
this
.
_register
(
new
ThrottledDelayer
<
URI
[]
>
(
AnythingQuickAccessProvider
.
TYPING_SEARCH_DELAY
));
private
fileQueryBuilder
=
this
.
instantiationService
.
createInstance
(
QueryBuilder
);
private
fileQueryBuilder
=
this
.
instantiationService
.
createInstance
(
QueryBuilder
);
...
@@ -283,9 +283,9 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
...
@@ -283,9 +283,9 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
}
}
// Use absolute path result as only results if present
// Use absolute path result as only results if present
let
fileMatches
:
Array
<
IFileMatch
<
URI
>
>
;
let
fileMatches
:
Array
<
URI
>
;
if
(
absolutePathResult
)
{
if
(
absolutePathResult
)
{
fileMatches
=
[
{
resource
:
absolutePathResult
}
];
fileMatches
=
[
absolutePathResult
];
}
}
// Otherwise run the file search (with a delayer if cache is not ready yet)
// Otherwise run the file search (with a delayer if cache is not ready yet)
...
@@ -309,12 +309,15 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
...
@@ -309,12 +309,15 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
// Filter excludes & convert to picks
// Filter excludes & convert to picks
return
fileMatches
return
fileMatches
.
filter
(
fileMatch
=>
!
excludes
.
has
(
fileMatch
.
resource
))
.
filter
(
resource
=>
!
excludes
.
has
(
resource
))
.
map
(
fileMatch
=>
this
.
createAnythingPick
(
fileMatch
.
resource
));
.
map
(
resource
=>
this
.
createAnythingPick
(
resource
));
}
}
private
async
doFileSearch
(
query
:
IPreparedQuery
,
token
:
CancellationToken
):
Promise
<
IFileMatch
[]
>
{
private
async
doFileSearch
(
query
:
IPreparedQuery
,
token
:
CancellationToken
):
Promise
<
URI
[]
>
{
const
{
results
}
=
await
this
.
searchService
.
fileSearch
(
const
[
fileSearchResults
,
relativePathFileResults
]
=
await
Promise
.
all
([
// File search: this is a search over all files of the workspace using the provided pattern
this
.
searchService
.
fileSearch
(
this
.
fileQueryBuilder
.
file
(
this
.
fileQueryBuilder
.
file
(
this
.
contextService
.
getWorkspace
().
folders
,
this
.
contextService
.
getWorkspace
().
folders
,
this
.
getFileQueryOptions
({
this
.
getFileQueryOptions
({
...
@@ -322,9 +325,19 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
...
@@ -322,9 +325,19 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
cacheKey
:
this
.
pickState
.
fileQueryCache
?.
cacheKey
,
cacheKey
:
this
.
pickState
.
fileQueryCache
?.
cacheKey
,
maxResults
:
AnythingQuickAccessProvider
.
MAX_RESULTS
maxResults
:
AnythingQuickAccessProvider
.
MAX_RESULTS
})
})
),
token
);
),
token
),
// Relative path search: we also want to consider results that match files inside the workspace
// by looking for relative paths that the user typed as query. This allows to return even excluded
// results into the picker if found (e.g. helps for opening compilation results that are otherwise
// excluded)
this
.
getRelativePathFileResults
(
query
,
token
)
]);
return
results
;
return
[
...
fileSearchResults
.
results
.
map
(
result
=>
result
.
resource
),
...(
relativePathFileResults
||
[])
];
}
}
private
getFileQueryOptions
(
input
:
{
filePattern
?:
string
,
cacheKey
?:
string
,
maxResults
?:
number
}):
IFileQueryBuilderOptions
{
private
getFileQueryOptions
(
input
:
{
filePattern
?:
string
,
cacheKey
?:
string
,
maxResults
?:
number
}):
IFileQueryBuilderOptions
{
...
@@ -341,7 +354,11 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
...
@@ -341,7 +354,11 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
}
}
private
async
getAbsolutePathFileResult
(
query
:
IPreparedQuery
,
token
:
CancellationToken
):
Promise
<
URI
|
undefined
>
{
private
async
getAbsolutePathFileResult
(
query
:
IPreparedQuery
,
token
:
CancellationToken
):
Promise
<
URI
|
undefined
>
{
const
detildifiedQuery
=
untildify
(
query
.
original
,
(
await
this
.
remotePathService
.
userHome
).
path
);
if
(
!
query
.
containsPathSeparator
)
{
return
;
}
const
detildifiedQuery
=
untildify
(
query
.
value
,
(
await
this
.
remotePathService
.
userHome
).
path
);
if
(
token
.
isCancellationRequested
)
{
if
(
token
.
isCancellationRequested
)
{
return
;
return
;
}
}
...
@@ -362,10 +379,47 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
...
@@ -362,10 +379,47 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
}
}
try
{
try
{
return
(
await
this
.
fileService
.
resolve
(
resource
)).
isDirectory
?
undefined
:
resource
;
if
((
await
this
.
fileService
.
resolve
(
resource
)).
isFile
)
{
return
resource
;
}
}
catch
(
error
)
{
// ignore if file does not exist
}
}
return
;
}
private
async
getRelativePathFileResults
(
query
:
IPreparedQuery
,
token
:
CancellationToken
):
Promise
<
URI
[]
|
undefined
>
{
if
(
!
query
.
containsPathSeparator
)
{
return
;
}
// Convert relative paths to absolute paths over all folders of the workspace
// and return them as results if the absolute paths exist
const
isAbsolutePathQuery
=
(
await
this
.
remotePathService
.
path
).
isAbsolute
(
query
.
value
);
if
(
!
isAbsolutePathQuery
)
{
const
resources
:
URI
[]
=
[];
for
(
const
folder
of
this
.
contextService
.
getWorkspace
().
folders
)
{
if
(
token
.
isCancellationRequested
)
{
break
;
}
const
resource
=
toLocalResource
(
folder
.
toResource
(
query
.
value
),
this
.
environmentService
.
configuration
.
remoteAuthority
);
try
{
if
((
await
this
.
fileService
.
resolve
(
resource
)).
isFile
)
{
resources
.
push
(
resource
);
}
}
catch
(
error
)
{
}
catch
(
error
)
{
// ignore
// ignore if file does not exist
}
}
}
return
resources
;
}
}
return
;
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录