Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
479d4e6e
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,发现更多精彩内容 >>
提交
479d4e6e
编写于
12月 13, 2019
作者:
R
Robert Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add string descriptions to SearchSortOrder enum
上级
6c8e4a2d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
29 deletion
+29
-29
src/vs/workbench/contrib/search/browser/search.contribution.ts
...s/workbench/contrib/search/browser/search.contribution.ts
+3
-3
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+8
-8
src/vs/workbench/contrib/search/common/searchModel.ts
src/vs/workbench/contrib/search/common/searchModel.ts
+7
-7
src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts
...rkbench/contrib/search/test/browser/searchViewlet.test.ts
+3
-3
src/vs/workbench/services/search/common/search.ts
src/vs/workbench/services/search/common/search.ts
+8
-8
未找到文件。
src/vs/workbench/contrib/search/browser/search.contribution.ts
浏览文件 @
479d4e6e
...
...
@@ -51,7 +51,7 @@ import { ISearchHistoryService, SearchHistoryService } from 'vs/workbench/contri
import
{
FileMatchOrMatch
,
ISearchWorkbenchService
,
RenderableMatch
,
SearchWorkbenchService
,
FileMatch
,
Match
,
FolderMatch
}
from
'
vs/workbench/contrib/search/common/searchModel
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
ISearchConfiguration
,
ISearchConfigurationProperties
,
PANEL_ID
,
VIEWLET_ID
,
VIEW_ID
,
VIEW_CONTAINER
,
SearchSortOrder
Configuration
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ISearchConfiguration
,
ISearchConfigurationProperties
,
PANEL_ID
,
VIEWLET_ID
,
VIEW_ID
,
VIEW_CONTAINER
,
SearchSortOrder
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ExplorerViewPaneContainer
}
from
'
vs/workbench/contrib/files/browser/explorerViewlet
'
;
...
...
@@ -829,8 +829,8 @@ configurationRegistry.registerConfiguration({
},
'
search.sortOrder
'
:
{
'
type
'
:
'
string
'
,
'
enum
'
:
[
SearchSortOrder
Configuration
.
default
,
SearchSortOrderConfiguration
.
fileNames
,
SearchSortOrderConfiguration
.
type
,
SearchSortOrderConfiguration
.
modified
,
SearchSortOrderConfiguration
.
countDescending
,
SearchSortOrderConfiguration
.
c
ountAscending
],
'
default
'
:
SearchSortOrder
Configuration
.
d
efault
,
'
enum
'
:
[
SearchSortOrder
.
Default
,
SearchSortOrder
.
FileNames
,
SearchSortOrder
.
Type
,
SearchSortOrder
.
Modified
,
SearchSortOrder
.
CountDescending
,
SearchSortOrder
.
C
ountAscending
],
'
default
'
:
SearchSortOrder
.
D
efault
,
'
enumDescriptions
'
:
[
nls
.
localize
(
'
searchSortOrder.default
'
,
'
Results are sorted by folder and file names, in alphabetical order.
'
),
nls
.
localize
(
'
searchSortOrder.filesOnly
'
,
'
Results are sorted by file names ignoring folder order, in alphabetical order.
'
),
...
...
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
479d4e6e
...
...
@@ -34,7 +34,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
TreeResourceNavigator2
,
WorkbenchObjectTree
,
getSelectionKeyboardEvent
}
from
'
vs/platform/list/browser/listService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IProgressService
,
IProgressStep
,
IProgress
}
from
'
vs/platform/progress/common/progress
'
;
import
{
IPatternInfo
,
ISearchComplete
,
ISearchConfiguration
,
ISearchConfigurationProperties
,
ITextQuery
,
VIEW_ID
,
VIEWLET_ID
,
SearchSortOrder
Configuration
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IPatternInfo
,
ISearchComplete
,
ISearchConfiguration
,
ISearchConfigurationProperties
,
ITextQuery
,
VIEW_ID
,
VIEWLET_ID
,
SearchSortOrder
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ISearchHistoryService
,
ISearchHistoryValues
}
from
'
vs/workbench/contrib/search/common/searchHistoryService
'
;
import
{
diffInserted
,
diffInsertedOutline
,
diffRemoved
,
diffRemovedOutline
,
editorFindMatchHighlight
,
editorFindMatchHighlightBorder
,
listActiveSelectionForeground
,
foreground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ICssStyleCollector
,
ITheme
,
IThemeService
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -196,7 +196,7 @@ export class SearchView extends ViewPane {
});
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
if
(
e
.
affectsConfiguration
(
'
search.sortOrder
'
))
{
if
(
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
Configuration
.
m
odified
)
{
if
(
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
.
M
odified
)
{
// If changing away from modified, remove all fileStats
// so that updated files are re-retrieved next time.
this
.
removeFileStats
();
...
...
@@ -505,7 +505,7 @@ export class SearchView extends ViewPane {
const
collapseResults
=
this
.
searchConfig
.
collapseResults
;
if
(
!
event
||
event
.
added
||
event
.
removed
)
{
// Refresh whole tree
if
(
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
Configuration
.
m
odified
)
{
if
(
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
.
M
odified
)
{
// Ensure all matches have retrieved their file stat
this
.
retrieveFileStats
()
.
then
(()
=>
this
.
tree
.
setChildren
(
null
,
this
.
createResultIterator
(
collapseResults
)));
...
...
@@ -514,8 +514,8 @@ export class SearchView extends ViewPane {
}
}
else
{
// If updated counts affect our search order, re-sort the view.
if
(
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
Configuration
.
c
ountAscending
||
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
Configuration
.
c
ountDescending
)
{
if
(
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
.
C
ountAscending
||
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
.
C
ountDescending
)
{
this
.
tree
.
setChildren
(
null
,
this
.
createResultIterator
(
collapseResults
));
}
else
{
// FileMatch modified, refresh those elements
...
...
@@ -1715,7 +1715,7 @@ export class SearchView extends ViewPane {
}
private
onFilesChanged
(
e
:
FileChangesEvent
):
void
{
if
(
!
this
.
viewModel
||
(
this
.
searchConfig
.
sortOrder
!==
SearchSortOrder
Configuration
.
m
odified
&&
!
e
.
gotDeleted
()))
{
if
(
!
this
.
viewModel
||
(
this
.
searchConfig
.
sortOrder
!==
SearchSortOrder
.
M
odified
&&
!
e
.
gotDeleted
()))
{
return
;
}
...
...
@@ -1727,7 +1727,7 @@ export class SearchView extends ViewPane {
}
else
{
// Check if the changed file contained matches
const
changedMatches
=
matches
.
filter
(
m
=>
e
.
contains
(
m
.
resource
));
if
(
changedMatches
.
length
&&
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
Configuration
.
m
odified
)
{
if
(
changedMatches
.
length
&&
this
.
searchConfig
.
sortOrder
===
SearchSortOrder
.
M
odified
)
{
// No matches need to be removed, but modified files need to have their file stat updated.
this
.
updateFileStats
(
changedMatches
).
then
(()
=>
this
.
refreshTree
());
}
...
...
@@ -1809,7 +1809,7 @@ export class SearchView extends ViewPane {
}
private
async
updateFileStats
(
elements
:
FileMatch
[]):
Promise
<
void
>
{
const
files
=
this
.
searchResult
.
matches
()
.
map
(
f
=>
f
.
resolveFileStat
(
this
.
fileService
));
const
files
=
elements
.
map
(
f
=>
f
.
resolveFileStat
(
this
.
fileService
));
await
Promise
.
all
(
files
);
}
...
...
src/vs/workbench/contrib/search/common/searchModel.ts
浏览文件 @
479d4e6e
...
...
@@ -20,7 +20,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IProgress
,
IProgressStep
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ReplacePattern
}
from
'
vs/workbench/services/search/common/replace
'
;
import
{
IFileMatch
,
IPatternInfo
,
ISearchComplete
,
ISearchProgressItem
,
ISearchConfigurationProperties
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
ITextSearchMatch
,
ITextSearchStats
,
resultIsMatch
,
ISearchRange
,
OneLineRange
,
ITextSearchContext
,
ITextSearchResult
,
SearchSortOrder
Configuration
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IFileMatch
,
IPatternInfo
,
ISearchComplete
,
ISearchProgressItem
,
ISearchConfigurationProperties
,
ISearchService
,
ITextQuery
,
ITextSearchPreviewOptions
,
ITextSearchMatch
,
ITextSearchStats
,
resultIsMatch
,
ISearchRange
,
OneLineRange
,
ITextSearchContext
,
ITextSearchResult
,
SearchSortOrder
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
overviewRulerFindMatchForeground
,
minimapFindMatch
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
themeColorFromId
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -643,22 +643,22 @@ export class FolderMatchWithResource extends FolderMatch {
* Compares instances of the same match type. Different match types should not be siblings
* and their sort order is undefined.
*/
export
function
searchMatchComparer
(
elementA
:
RenderableMatch
,
elementB
:
RenderableMatch
,
sortOrder
:
SearchSortOrder
Configuration
=
SearchSortOrderConfiguration
.
d
efault
):
number
{
export
function
searchMatchComparer
(
elementA
:
RenderableMatch
,
elementB
:
RenderableMatch
,
sortOrder
:
SearchSortOrder
=
SearchSortOrder
.
D
efault
):
number
{
if
(
elementA
instanceof
FolderMatch
&&
elementB
instanceof
FolderMatch
)
{
return
elementA
.
index
()
-
elementB
.
index
();
}
if
(
elementA
instanceof
FileMatch
&&
elementB
instanceof
FileMatch
)
{
switch
(
sortOrder
)
{
case
SearchSortOrder
Configuration
.
c
ountDescending
:
case
SearchSortOrder
.
C
ountDescending
:
return
elementB
.
count
()
-
elementA
.
count
();
case
SearchSortOrder
Configuration
.
c
ountAscending
:
case
SearchSortOrder
.
C
ountAscending
:
return
elementA
.
count
()
-
elementB
.
count
();
case
SearchSortOrder
Configuration
.
t
ype
:
case
SearchSortOrder
.
T
ype
:
return
compareFileExtensions
(
elementA
.
name
(),
elementB
.
name
());
case
SearchSortOrder
Configuration
.
f
ileNames
:
case
SearchSortOrder
.
F
ileNames
:
return
compareFileNames
(
elementA
.
name
(),
elementB
.
name
());
case
SearchSortOrder
Configuration
.
m
odified
:
case
SearchSortOrder
.
M
odified
:
const
fileStatA
=
elementA
.
fileStat
;
const
fileStatB
=
elementB
.
fileStat
;
if
(
fileStatA
&&
fileStatB
)
{
...
...
src/vs/workbench/contrib/search/test/browser/searchViewlet.test.ts
浏览文件 @
479d4e6e
...
...
@@ -9,7 +9,7 @@ import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
TestInstantiationService
}
from
'
vs/platform/instantiation/test/common/instantiationServiceMock
'
;
import
{
IFileMatch
,
ITextSearchMatch
,
OneLineRange
,
QueryType
,
SearchSortOrder
Configuration
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IFileMatch
,
ITextSearchMatch
,
OneLineRange
,
QueryType
,
SearchSortOrder
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
TestWorkspace
}
from
'
vs/platform/workspace/test/common/testWorkspace
'
;
import
{
FileMatch
,
Match
,
searchMatchComparer
,
SearchResult
}
from
'
vs/workbench/contrib/search/common/searchModel
'
;
...
...
@@ -90,9 +90,9 @@ suite('Search - Viewlet', () => {
// By default, path < path2
assert
(
searchMatchComparer
(
fileMatch1
,
fileMatch2
)
<
0
);
// By filenames, foo10 > foo1
assert
(
searchMatchComparer
(
fileMatch1
,
fileMatch2
,
SearchSortOrder
Configuration
.
f
ileNames
)
>
0
);
assert
(
searchMatchComparer
(
fileMatch1
,
fileMatch2
,
SearchSortOrder
.
F
ileNames
)
>
0
);
// By type, bar.a < bar.b
assert
(
searchMatchComparer
(
fileMatch3
,
fileMatch4
,
SearchSortOrder
Configuration
.
t
ype
)
<
0
);
assert
(
searchMatchComparer
(
fileMatch3
,
fileMatch4
,
SearchSortOrder
.
T
ype
)
<
0
);
});
function
aFileMatch
(
path
:
string
,
searchResult
?:
SearchResult
,
...
lineMatches
:
ITextSearchMatch
[]):
FileMatch
{
...
...
src/vs/workbench/services/search/common/search.ts
浏览文件 @
479d4e6e
...
...
@@ -311,13 +311,13 @@ export class OneLineRange extends SearchRange {
}
}
export
const
enum
SearchSortOrder
Configuration
{
default
,
fileNames
,
type
,
modified
,
countDescending
,
countAscending
export
const
enum
SearchSortOrder
{
Default
=
'
default
'
,
FileNames
=
'
fileNames
'
,
Type
=
'
type
'
,
Modified
=
'
modified
'
,
CountDescending
=
'
countDescending
'
,
CountAscending
=
'
countAscending
'
}
export
interface
ISearchConfigurationProperties
{
...
...
@@ -342,7 +342,7 @@ export interface ISearchConfigurationProperties {
searchOnTypeDebouncePeriod
:
number
;
enableSearchEditorPreview
:
boolean
;
searchEditorPreviewForceAbsolutePaths
:
boolean
;
sortOrder
:
SearchSortOrder
Configuration
;
sortOrder
:
SearchSortOrder
;
}
export
interface
ISearchConfiguration
extends
IFilesConfiguration
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录