Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4132c13a
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,发现更多精彩内容 >>
提交
4132c13a
编写于
6月 11, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #42726
上级
4ac711ab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
28 deletion
+52
-28
src/vs/workbench/parts/search/browser/openAnythingHandler.ts
src/vs/workbench/parts/search/browser/openAnythingHandler.ts
+3
-3
src/vs/workbench/parts/search/browser/openFileHandler.ts
src/vs/workbench/parts/search/browser/openFileHandler.ts
+49
-25
未找到文件。
src/vs/workbench/parts/search/browser/openAnythingHandler.ts
浏览文件 @
4132c13a
...
@@ -108,12 +108,12 @@ export class OpenAnythingHandler extends QuickOpenHandler {
...
@@ -108,12 +108,12 @@ export class OpenAnythingHandler extends QuickOpenHandler {
const
resultPromises
:
TPromise
<
QuickOpenModel
|
FileQuickOpenModel
>
[]
=
[];
const
resultPromises
:
TPromise
<
QuickOpenModel
|
FileQuickOpenModel
>
[]
=
[];
// File Results
// File Results
const
filePromise
=
this
.
openFileHandler
.
getResults
(
query
.
value
,
OpenAnythingHandler
.
MAX_DISPLAYED_RESULTS
);
const
filePromise
=
this
.
openFileHandler
.
getResults
(
query
.
original
,
OpenAnythingHandler
.
MAX_DISPLAYED_RESULTS
);
resultPromises
.
push
(
filePromise
);
resultPromises
.
push
(
filePromise
);
// Symbol Results (unless disabled or a range or absolute path is specified)
// Symbol Results (unless disabled or a range or absolute path is specified)
if
(
this
.
includeSymbols
&&
!
searchWithRange
)
{
if
(
this
.
includeSymbols
&&
!
searchWithRange
)
{
resultPromises
.
push
(
this
.
openSymbolHandler
.
getResults
(
query
.
value
));
resultPromises
.
push
(
this
.
openSymbolHandler
.
getResults
(
query
.
original
));
}
}
// Join and sort unified
// Join and sort unified
...
@@ -263,4 +263,4 @@ export class OpenAnythingHandler extends QuickOpenHandler {
...
@@ -263,4 +263,4 @@ export class OpenAnythingHandler extends QuickOpenHandler {
this
.
pendingSearch
=
null
;
this
.
pendingSearch
=
null
;
}
}
}
}
}
}
\ No newline at end of file
src/vs/workbench/parts/search/browser/openFileHandler.ts
浏览文件 @
4132c13a
...
@@ -32,6 +32,8 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
...
@@ -32,6 +32,8 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
getOutOfWorkspaceEditorResources
}
from
'
vs/workbench/parts/search/common/search
'
;
import
{
getOutOfWorkspaceEditorResources
}
from
'
vs/workbench/parts/search/common/search
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
prepareQuery
,
IPreparedQuery
}
from
'
vs/base/parts/quickopen/common/quickOpenScorer
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
export
class
FileQuickOpenModel
extends
QuickOpenModel
{
export
class
FileQuickOpenModel
extends
QuickOpenModel
{
...
@@ -122,7 +124,8 @@ export class OpenFileHandler extends QuickOpenHandler {
...
@@ -122,7 +124,8 @@ export class OpenFileHandler extends QuickOpenHandler {
@
IWorkbenchThemeService
private
themeService
:
IWorkbenchThemeService
,
@
IWorkbenchThemeService
private
themeService
:
IWorkbenchThemeService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
ISearchService
private
searchService
:
ISearchService
,
@
ISearchService
private
searchService
:
ISearchService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IFileService
private
fileService
:
IFileService
)
{
)
{
super
();
super
();
...
@@ -134,50 +137,71 @@ export class OpenFileHandler extends QuickOpenHandler {
...
@@ -134,50 +137,71 @@ export class OpenFileHandler extends QuickOpenHandler {
}
}
public
getResults
(
searchValue
:
string
,
maxSortedResults
?:
number
):
TPromise
<
FileQuickOpenModel
>
{
public
getResults
(
searchValue
:
string
,
maxSortedResults
?:
number
):
TPromise
<
FileQuickOpenModel
>
{
searchValue
=
searchValue
.
trim
(
);
const
query
=
prepareQuery
(
searchValue
);
// Respond directly to empty search
// Respond directly to empty search
if
(
!
searchV
alue
)
{
if
(
!
query
.
v
alue
)
{
return
TPromise
.
as
(
new
FileQuickOpenModel
([]));
return
TPromise
.
as
(
new
FileQuickOpenModel
([]));
}
}
// Untildify file pattern
// Untildify file pattern
searchValue
=
labels
.
untildify
(
searchV
alue
,
this
.
environmentService
.
userHome
);
query
.
value
=
labels
.
untildify
(
query
.
v
alue
,
this
.
environmentService
.
userHome
);
// Do find results
// Do find results
return
this
.
doFindResults
(
searchValue
,
this
.
cacheState
.
cacheKey
,
maxSortedResults
);
return
this
.
doFindResults
(
query
,
this
.
cacheState
.
cacheKey
,
maxSortedResults
);
}
}
private
doFindResults
(
searchValue
:
string
,
cacheKey
?:
string
,
maxSortedResults
?:
number
):
TPromise
<
FileQuickOpenModel
>
{
private
doFindResults
(
query
:
IPreparedQuery
,
cacheKey
?:
string
,
maxSortedResults
?:
number
):
TPromise
<
FileQuickOpenModel
>
{
const
query
:
IQueryOptions
=
{
return
this
.
doResolveQueryOptions
(
query
,
cacheKey
,
maxSortedResults
).
then
(
queryOptions
=>
{
let
iconClass
:
string
;
if
(
this
.
options
&&
this
.
options
.
forceUseIcons
&&
!
this
.
themeService
.
getFileIconTheme
())
{
iconClass
=
'
file
'
;
// only use a generic file icon if we are forced to use an icon and have no icon theme set otherwise
}
return
this
.
searchService
.
search
(
this
.
queryBuilder
.
file
(
this
.
contextService
.
getWorkspace
().
folders
.
map
(
folder
=>
folder
.
uri
),
queryOptions
)).
then
(
complete
=>
{
const
results
:
QuickOpenEntry
[]
=
[];
for
(
let
i
=
0
;
i
<
complete
.
results
.
length
;
i
++
)
{
const
fileMatch
=
complete
.
results
[
i
];
const
label
=
paths
.
basename
(
fileMatch
.
resource
.
fsPath
);
const
description
=
labels
.
getPathLabel
(
resources
.
dirname
(
fileMatch
.
resource
),
this
.
contextService
,
this
.
environmentService
);
results
.
push
(
this
.
instantiationService
.
createInstance
(
FileEntry
,
fileMatch
.
resource
,
label
,
description
,
iconClass
));
}
return
new
FileQuickOpenModel
(
results
,
complete
.
stats
);
});
});
}
private
doResolveQueryOptions
(
query
:
IPreparedQuery
,
cacheKey
?:
string
,
maxSortedResults
?:
number
):
TPromise
<
IQueryOptions
>
{
const
queryOptions
:
IQueryOptions
=
{
extraFileResources
:
getOutOfWorkspaceEditorResources
(
this
.
editorService
,
this
.
contextService
),
extraFileResources
:
getOutOfWorkspaceEditorResources
(
this
.
editorService
,
this
.
contextService
),
filePattern
:
searchV
alue
,
filePattern
:
query
.
v
alue
,
cacheKey
:
cacheKey
cacheKey
};
};
if
(
typeof
maxSortedResults
===
'
number
'
)
{
if
(
typeof
maxSortedResults
===
'
number
'
)
{
query
.
maxResults
=
maxSortedResults
;
query
Options
.
maxResults
=
maxSortedResults
;
query
.
sortByScore
=
true
;
query
Options
.
sortByScore
=
true
;
}
}
let
iconClass
:
string
;
let
queryIsAbsoluteFilePromise
:
TPromise
<
URI
>
;
if
(
this
.
options
&&
this
.
options
.
forceUseIcons
&&
!
this
.
themeService
.
getFileIconTheme
())
{
if
(
paths
.
isAbsolute
(
query
.
original
))
{
iconClass
=
'
file
'
;
// only use a generic file icon if we are forced to use an icon and have no icon theme set otherwise
const
resource
=
URI
.
file
(
query
.
original
);
queryIsAbsoluteFilePromise
=
this
.
fileService
.
resolveFile
(
resource
).
then
(
stat
=>
stat
.
isDirectory
?
void
0
:
resource
,
error
=>
void
0
);
}
else
{
queryIsAbsoluteFilePromise
=
TPromise
.
as
(
null
);
}
}
const
folderResources
=
this
.
contextService
.
getWorkspace
().
folders
.
map
(
folder
=>
folder
.
uri
);
return
queryIsAbsoluteFilePromise
.
then
(
resource
=>
{
return
this
.
searchService
.
search
(
this
.
queryBuilder
.
file
(
folderResources
,
query
)).
then
((
complete
)
=>
{
if
(
resource
)
{
const
results
:
QuickOpenEntry
[]
=
[];
// if the original search value is an existing file on disk, add it to the
for
(
let
i
=
0
;
i
<
complete
.
results
.
length
;
i
++
)
{
// extra file resources to consider (fixes https://github.com/Microsoft/vscode/issues/42726)
const
fileMatch
=
complete
.
results
[
i
];
queryOptions
.
extraFileResources
.
push
(
resource
);
const
label
=
paths
.
basename
(
fileMatch
.
resource
.
fsPath
);
const
description
=
labels
.
getPathLabel
(
resources
.
dirname
(
fileMatch
.
resource
),
this
.
contextService
,
this
.
environmentService
);
results
.
push
(
this
.
instantiationService
.
createInstance
(
FileEntry
,
fileMatch
.
resource
,
label
,
description
,
iconClass
));
}
}
return
new
FileQuickOpenModel
(
results
,
complete
.
stats
)
;
return
queryOptions
;
});
});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录