Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
879fd0d0
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,发现更多精彩内容 >>
提交
879fd0d0
编写于
8月 14, 2017
作者:
K
Keegan Carruthers-Smith
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add remove action for FolderMatch
上级
a7fcaffc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
17 deletion
+36
-17
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+22
-14
src/vs/workbench/parts/search/browser/searchResultsView.ts
src/vs/workbench/parts/search/browser/searchResultsView.ts
+6
-1
src/vs/workbench/parts/search/common/searchModel.ts
src/vs/workbench/parts/search/common/searchModel.ts
+8
-2
未找到文件。
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
879fd0d0
...
...
@@ -15,7 +15,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
INavigator
}
from
'
vs/base/common/iterator
'
;
import
{
SearchViewlet
}
from
'
vs/workbench/parts/search/browser/searchViewlet
'
;
import
{
Match
,
FileMatch
,
FileMatchOrMatch
,
FolderMatch
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
Match
,
FileMatch
,
FileMatchOrMatch
,
FolderMatch
,
RenderableMatch
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
IReplaceService
}
from
'
vs/workbench/parts/search/common/replace
'
;
import
*
as
Constants
from
'
vs/workbench/parts/search/common/constants
'
;
import
{
CollapseAllAction
as
TreeCollapseAction
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
...
...
@@ -465,7 +465,7 @@ export abstract class AbstractSearchAndReplaceAction extends Action {
/**
* Returns element to focus after removing the given element
*/
public
getElementToFocusAfterRemoved
(
viewer
:
ITree
,
elementToBeRemoved
:
FileMatchOrMatch
):
FileMatchOr
Match
{
public
getElementToFocusAfterRemoved
(
viewer
:
ITree
,
elementToBeRemoved
:
RenderableMatch
):
Renderable
Match
{
let
elementToFocus
=
this
.
getNextElementAfterRemoved
(
viewer
,
elementToBeRemoved
);
if
(
!
elementToFocus
)
{
elementToFocus
=
this
.
getPreviousElementAfterRemoved
(
viewer
,
elementToBeRemoved
);
...
...
@@ -473,9 +473,12 @@ export abstract class AbstractSearchAndReplaceAction extends Action {
return
elementToFocus
;
}
public
getNextElementAfterRemoved
(
viewer
:
ITree
,
element
:
FileMatchOrMatch
):
FileMatchOr
Match
{
public
getNextElementAfterRemoved
(
viewer
:
ITree
,
element
:
RenderableMatch
):
Renderable
Match
{
let
navigator
:
INavigator
<
any
>
=
this
.
getNavigatorAt
(
element
,
viewer
);
if
(
element
instanceof
FileMatch
)
{
if
(
element
instanceof
FolderMatch
)
{
// If file match is removed then next element is the next file match
while
(
!!
navigator
.
next
()
&&
!
(
navigator
.
current
()
instanceof
FolderMatch
))
{
};
}
else
if
(
element
instanceof
FileMatch
)
{
// If file match is removed then next element is the next file match
while
(
!!
navigator
.
next
()
&&
!
(
navigator
.
current
()
instanceof
FileMatch
))
{
};
}
else
{
...
...
@@ -484,7 +487,7 @@ export abstract class AbstractSearchAndReplaceAction extends Action {
return
navigator
.
current
();
}
public
getPreviousElementAfterRemoved
(
viewer
:
ITree
,
element
:
FileMatchOrMatch
):
FileMatchOr
Match
{
public
getPreviousElementAfterRemoved
(
viewer
:
ITree
,
element
:
RenderableMatch
):
Renderable
Match
{
let
navigator
:
INavigator
<
any
>
=
this
.
getNavigatorAt
(
element
,
viewer
);
let
previousElement
=
navigator
.
previous
();
if
(
element
instanceof
Match
&&
element
.
parent
().
matches
().
length
===
1
)
{
...
...
@@ -495,7 +498,7 @@ export abstract class AbstractSearchAndReplaceAction extends Action {
return
previousElement
;
}
private
getNavigatorAt
(
element
:
FileMatchOr
Match
,
viewer
:
ITree
):
INavigator
<
any
>
{
private
getNavigatorAt
(
element
:
Renderable
Match
,
viewer
:
ITree
):
INavigator
<
any
>
{
let
navigator
:
INavigator
<
any
>
=
viewer
.
getNavigator
();
while
(
navigator
.
current
()
!==
element
&&
!!
navigator
.
next
())
{
}
return
navigator
;
...
...
@@ -504,7 +507,7 @@ export abstract class AbstractSearchAndReplaceAction extends Action {
export
class
RemoveAction
extends
AbstractSearchAndReplaceAction
{
constructor
(
private
viewer
:
ITree
,
private
element
:
FileMatchOr
Match
)
{
constructor
(
private
viewer
:
ITree
,
private
element
:
Renderable
Match
)
{
super
(
'
remove
'
,
nls
.
localize
(
'
RemoveAction.label
'
,
"
Remove
"
),
'
action-remove
'
);
}
...
...
@@ -515,13 +518,18 @@ export class RemoveAction extends AbstractSearchAndReplaceAction {
}
let
elementToRefresh
:
any
;
if
(
this
.
element
instanceof
FileMatch
)
{
let
parent
:
FolderMatch
=
<
FolderMatch
>
this
.
element
.
parent
();
parent
.
remove
(
<
FileMatch
>
this
.
element
);
const
element
=
this
.
element
;
if
(
element
instanceof
FolderMatch
)
{
let
parent
=
element
.
parent
();
parent
.
remove
(
element
);
elementToRefresh
=
parent
;
}
else
{
let
parent
:
FileMatch
=
<
FileMatch
>
this
.
element
.
parent
();
parent
.
remove
(
<
Match
>
this
.
element
);
}
else
if
(
element
instanceof
FileMatch
)
{
let
parent
=
element
.
parent
();
parent
.
remove
(
element
);
elementToRefresh
=
parent
;
}
else
if
(
element
instanceof
Match
)
{
let
parent
=
element
.
parent
();
parent
.
remove
(
element
);
elementToRefresh
=
parent
.
count
()
===
0
?
parent
.
parent
()
:
parent
;
}
...
...
@@ -620,7 +628,7 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
return
null
;
}
private
hasSameParent
(
element
:
FileMatchOr
Match
):
boolean
{
private
hasSameParent
(
element
:
Renderable
Match
):
boolean
{
return
element
&&
element
instanceof
Match
&&
element
.
parent
().
resource
()
===
this
.
element
.
parent
().
resource
();
}
...
...
src/vs/workbench/parts/search/browser/searchResultsView.ts
浏览文件 @
879fd0d0
...
...
@@ -114,6 +114,7 @@ export class SearchSorter implements ISorter {
interface
IFolderMatchTemplate
{
label
:
FileLabel
;
badge
:
CountBadge
;
actions
:
ActionBar
;
}
interface
IFileMatchTemplate
{
...
...
@@ -193,7 +194,8 @@ export class SearchRenderer extends Disposable implements IRenderer {
const
label
=
this
.
instantiationService
.
createInstance
(
FileLabel
,
folderMatchElement
,
void
0
);
const
badge
=
new
CountBadge
(
DOM
.
append
(
folderMatchElement
,
DOM
.
$
(
'
.badge
'
)));
this
.
_register
(
attachBadgeStyler
(
badge
,
this
.
themeService
));
return
{
label
,
badge
};
const
actions
=
new
ActionBar
(
folderMatchElement
,
{
animated
:
false
});
return
{
label
,
badge
,
actions
};
}
private
renderFileMatchTemplate
(
tree
:
ITree
,
templateId
:
string
,
container
:
HTMLElement
):
IFileMatchTemplate
{
...
...
@@ -234,6 +236,9 @@ export class SearchRenderer extends Disposable implements IRenderer {
let
count
=
folderMatch
.
fileCount
();
templateData
.
badge
.
setCount
(
count
);
templateData
.
badge
.
setTitleFormat
(
count
>
1
?
nls
.
localize
(
'
searchFileMatches
'
,
"
{0} files found
"
,
count
)
:
nls
.
localize
(
'
searchFileMatch
'
,
"
{0} file found
"
,
count
));
templateData
.
actions
.
clear
();
templateData
.
actions
.
push
([
new
RemoveAction
(
tree
,
folderMatch
)],
{
icon
:
true
,
label
:
false
});
}
private
renderFileMatch
(
tree
:
ITree
,
fileMatch
:
FileMatch
,
templateData
:
IFileMatchTemplate
):
void
{
...
...
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
879fd0d0
...
...
@@ -549,8 +549,12 @@ export class SearchResult extends Disposable {
this
.
disposeMatches
();
}
public
remove
(
match
:
FileMatch
):
void
{
this
.
getFolderMatch
(
match
.
resource
()).
remove
(
match
);
public
remove
(
match
:
FileMatch
|
FolderMatch
):
void
{
if
(
match
instanceof
FileMatch
)
{
this
.
getFolderMatch
(
match
.
resource
()).
remove
(
match
);
}
else
{
match
.
clear
();
}
}
public
replace
(
match
:
FileMatch
):
TPromise
<
any
>
{
...
...
@@ -788,6 +792,8 @@ export class SearchModel extends Disposable {
export
type
FileMatchOrMatch
=
FileMatch
|
Match
;
export
type
RenderableMatch
=
FolderMatch
|
FileMatch
|
Match
;
export
class
SearchWorkbenchService
implements
ISearchWorkbenchService
{
_serviceBrand
:
any
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录