Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3e7c371e
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,发现更多精彩内容 >>
提交
3e7c371e
编写于
5月 01, 2018
作者:
S
Shiva Prasanth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
search results copy All with sort like tree
上级
55a10f77
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
30 deletion
+31
-30
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+24
-5
src/vs/workbench/parts/search/browser/searchResultsView.ts
src/vs/workbench/parts/search/browser/searchResultsView.ts
+2
-21
src/vs/workbench/parts/search/browser/searchView.ts
src/vs/workbench/parts/search/browser/searchView.ts
+3
-3
src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts
...workbench/parts/search/test/browser/searchViewlet.test.ts
+2
-1
未找到文件。
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
3e7c371e
...
...
@@ -8,10 +8,11 @@ import * as DOM from 'vs/base/browser/dom';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ITree
,
ISorter
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
INavigator
}
from
'
vs/base/common/iterator
'
;
import
{
SearchView
}
from
'
vs/workbench/parts/search/browser/searchView
'
;
import
{
Match
,
FileMatch
,
FileMatchOrMatch
,
FolderMatch
,
RenderableMatch
,
SearchResult
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IReplaceService
}
from
'
vs/workbench/parts/search/common/replace
'
;
import
*
as
Constants
from
'
vs/workbench/parts/search/common/constants
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -717,7 +718,6 @@ function fileMatchToString(fileMatch: FileMatch, maxMatches: number): { text: st
.
slice
(
0
,
maxMatches
)
.
map
(
matchToString
)
.
map
(
matchText
=>
'
'
+
matchText
);
return
{
text
:
`
${
uriToClipboardString
(
fileMatch
.
resource
())}${
lineDelimiter
}${
matchTextRows
.
join
(
lineDelimiter
)}
`
,
count
:
matchTextRows
.
length
...
...
@@ -728,8 +728,11 @@ function folderMatchToString(folderMatch: FolderMatch, maxMatches: number): { te
const
fileResults
:
string
[]
=
[];
let
numMatches
=
0
;
let
sorter
=
new
SearchSorter
();
let
matches
=
folderMatch
.
matches
().
sort
((
matchA
,
matchB
)
=>
sorter
.
compare
(
null
,
matchA
,
matchB
));
for
(
let
i
=
0
;
i
<
folderMatch
.
fileCount
()
&&
numMatches
<
maxMatches
;
i
++
)
{
const
fileResult
=
fileMatchToString
(
folderMatch
.
matches
()
[
i
],
maxMatches
-
numMatches
);
const
fileResult
=
fileMatchToString
(
matches
[
i
],
maxMatches
-
numMatches
);
numMatches
+=
fileResult
.
count
;
fileResults
.
push
(
fileResult
.
text
);
}
...
...
@@ -758,10 +761,26 @@ export const copyMatchCommand: ICommandHandler = (accessor, match: RenderableMat
}
};
export
class
SearchSorter
implements
ISorter
{
public
compare
(
tree
:
ITree
,
elementA
:
FileMatchOrMatch
,
elementB
:
FileMatchOrMatch
):
number
{
if
(
elementA
instanceof
FolderMatch
&&
elementB
instanceof
FolderMatch
)
{
return
elementA
.
index
()
-
elementB
.
index
();
}
if
(
elementA
instanceof
FileMatch
&&
elementB
instanceof
FileMatch
)
{
return
elementA
.
resource
().
fsPath
.
localeCompare
(
elementB
.
resource
().
fsPath
)
||
elementA
.
name
().
localeCompare
(
elementB
.
name
());
}
if
(
elementA
instanceof
Match
&&
elementB
instanceof
Match
)
{
return
Range
.
compareRangesUsingStarts
(
elementA
.
range
(),
elementB
.
range
());
}
return
undefined
;
}
}
function
allFolderMatchesToString
(
folderMatches
:
FolderMatch
[],
maxMatches
:
number
):
string
{
const
folderResults
:
string
[]
=
[];
let
numMatches
=
0
;
for
(
let
i
=
0
;
i
<
folderMatches
.
length
&&
numMatches
<
maxMatches
;
i
++
)
{
const
folderResult
=
folderMatchToString
(
folderMatches
[
i
],
maxMatches
-
numMatches
);
if
(
folderResult
.
count
)
{
...
...
@@ -791,4 +810,4 @@ export const clearHistoryCommand: ICommandHandler = accessor => {
const
searchView
=
getSearchView
(
viewletService
,
panelService
);
searchView
.
clearHistory
();
};
};
\ No newline at end of file
src/vs/workbench/parts/search/browser/searchResultsView.ts
浏览文件 @
3e7c371e
...
...
@@ -12,10 +12,9 @@ import { IAction, IActionRunner } from 'vs/base/common/actions';
import
{
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
CountBadge
}
from
'
vs/base/browser/ui/countBadge/countBadge
'
;
import
{
FileLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
ITree
,
IDataSource
,
I
Sorter
,
I
AccessibilityProvider
,
IFilter
,
IRenderer
,
ContextMenuEvent
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ITree
,
IDataSource
,
IAccessibilityProvider
,
IFilter
,
IRenderer
,
ContextMenuEvent
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
Match
,
SearchResult
,
FileMatch
,
FileMatchOrMatch
,
SearchModel
,
FolderMatch
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
SearchView
}
from
'
vs/workbench/parts/search/browser/searchView
'
;
import
{
RemoveAction
,
ReplaceAllAction
,
ReplaceAction
,
ReplaceAllInFolderAction
}
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -111,24 +110,6 @@ export class SearchDataSource implements IDataSource {
}
}
export
class
SearchSorter
implements
ISorter
{
public
compare
(
tree
:
ITree
,
elementA
:
FileMatchOrMatch
,
elementB
:
FileMatchOrMatch
):
number
{
if
(
elementA
instanceof
FolderMatch
&&
elementB
instanceof
FolderMatch
)
{
return
elementA
.
index
()
-
elementB
.
index
();
}
if
(
elementA
instanceof
FileMatch
&&
elementB
instanceof
FileMatch
)
{
return
elementA
.
resource
().
fsPath
.
localeCompare
(
elementB
.
resource
().
fsPath
)
||
elementA
.
name
().
localeCompare
(
elementB
.
name
());
}
if
(
elementA
instanceof
Match
&&
elementB
instanceof
Match
)
{
return
Range
.
compareRangesUsingStarts
(
elementA
.
range
(),
elementB
.
range
());
}
return
undefined
;
}
}
interface
IFolderMatchTemplate
{
label
:
FileLabel
;
...
...
@@ -395,4 +376,4 @@ export class SearchTreeController extends WorkbenchTreeController {
return
true
;
}
}
}
\ No newline at end of file
src/vs/workbench/parts/search/browser/searchView.ts
浏览文件 @
3e7c371e
...
...
@@ -41,9 +41,9 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
PatternInputWidget
,
ExcludePatternInputWidget
}
from
'
vs/workbench/parts/search/browser/patternInputWidget
'
;
import
{
SearchRenderer
,
SearchDataSource
,
Search
Sorter
,
Search
AccessibilityProvider
,
SearchFilter
,
SearchTreeController
}
from
'
vs/workbench/parts/search/browser/searchResultsView
'
;
import
{
SearchRenderer
,
SearchDataSource
,
SearchAccessibilityProvider
,
SearchFilter
,
SearchTreeController
}
from
'
vs/workbench/parts/search/browser/searchResultsView
'
;
import
{
SearchWidget
,
ISearchWidgetOptions
}
from
'
vs/workbench/parts/search/browser/searchWidget
'
;
import
{
RefreshAction
,
CollapseDeepestExpandedLevelAction
,
ClearSearchResultsAction
,
CancelSearchAction
}
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
SearchSorter
,
RefreshAction
,
CollapseDeepestExpandedLevelAction
,
ClearSearchResultsAction
,
CancelSearchAction
}
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
IReplaceService
}
from
'
vs/workbench/parts/search/common/replace
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
OpenFolderAction
,
OpenFileFolderAction
}
from
'
vs/workbench/browser/actions/workspaceActions
'
;
...
...
@@ -1585,4 +1585,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
if
(
findMatchHighlightBorder
)
{
collector
.
addRule
(
`.monaco-workbench .search-view .findInFileMatch { border: 1px
${
theme
.
type
===
'
hc
'
?
'
dashed
'
:
'
solid
'
}
${
findMatchHighlightBorder
}
; }`
);
}
});
});
\ No newline at end of file
src/vs/workbench/parts/search/test/browser/searchViewlet.test.ts
浏览文件 @
3e7c371e
...
...
@@ -8,7 +8,8 @@ import * as assert from 'assert';
import
uri
from
'
vs/base/common/uri
'
;
import
{
Match
,
FileMatch
,
SearchResult
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
TestInstantiationService
}
from
'
vs/platform/instantiation/test/common/instantiationServiceMock
'
;
import
{
SearchSorter
,
SearchDataSource
}
from
'
vs/workbench/parts/search/browser/searchResultsView
'
;
import
{
SearchSorter
}
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
SearchDataSource
}
from
'
vs/workbench/parts/search/browser/searchResultsView
'
;
import
{
IFileMatch
,
ILineMatch
}
from
'
vs/platform/search/common/search
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录