Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ec89a599
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,发现更多精彩内容 >>
提交
ec89a599
编写于
4月 10, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#23912 Adopt actions
上级
735c6d3b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
41 deletion
+63
-41
src/vs/workbench/parts/search/browser/media/searchviewlet.css
...vs/workbench/parts/search/browser/media/searchviewlet.css
+36
-2
src/vs/workbench/parts/search/browser/searchResultsView.ts
src/vs/workbench/parts/search/browser/searchResultsView.ts
+27
-39
未找到文件。
src/vs/workbench/parts/search/browser/media/searchviewlet.css
浏览文件 @
ec89a599
...
...
@@ -188,10 +188,15 @@
}
.search-viewlet
.linematch
{
overflow
:
hidden
;
text-overflow
:
ellipsis
;
position
:
relative
;
line-height
:
22px
;
display
:
flex
;
}
.search-viewlet
.linematch
>
.match
{
flex
:
1
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
}
.search-viewlet
.linematch.changedOrRemoved
{
...
...
@@ -224,6 +229,35 @@
background
:
url("action-query-clear.svg")
center
center
no-repeat
;
}
.search-viewlet
.monaco-tree
.monaco-tree-row
.monaco-action-bar
{
line-height
:
1em
;
display
:
none
;
padding
:
0
0.8em
0
0.4em
;
}
.search-viewlet
.monaco-tree
.monaco-tree-row
.monaco-action-bar
.action-item
{
margin
:
0
;
}
.search-viewlet
.monaco-tree
.monaco-tree-row.focused
.monaco-action-bar
{
width
:
0
;
/* in order to support a11y with keyboard, we use width: 0 to hide the actions, which still allows to "Tab" into the actions */
display
:
block
;
}
.search-viewlet
.monaco-tree
.monaco-tree-row
:hover:not
(
.highlighted
)
.monaco-action-bar
,
.search-viewlet
.monaco-tree
.monaco-tree-row.focused
.monaco-action-bar
{
width
:
inherit
;
display
:
block
;
}
.search-viewlet
.monaco-tree
.monaco-tree-row
.monaco-action-bar
.action-label
{
margin-right
:
0.2em
;
margin-top
:
4px
;
background-repeat
:
no-repeat
;
width
:
16px
;
height
:
16px
;
}
.search-viewlet
.action-remove
{
background
:
url("action-remove.svg")
center
center
no-repeat
;
}
...
...
src/vs/workbench/parts/search/browser/searchResultsView.ts
浏览文件 @
ec89a599
...
...
@@ -12,11 +12,11 @@ import * as DOM from 'vs/base/browser/dom';
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
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
,
ISorter
,
IAccessibilityProvider
,
IFilter
,
IRenderer
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ClickBehavior
,
DefaultController
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
Match
,
SearchResult
,
FileMatch
,
FileMatchOrMatch
,
SearchModel
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -93,40 +93,10 @@ export class SearchSorter implements ISorter {
}
}
class
SearchActionProvider
extends
ContributableActionProvider
{
constructor
(
private
viewlet
:
SearchViewlet
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
();
}
public
hasActions
(
tree
:
ITree
,
element
:
any
):
boolean
{
let
input
=
<
SearchResult
>
tree
.
getInput
();
return
element
instanceof
FileMatch
||
(
element
instanceof
Match
&&
input
.
searchModel
.
isReplaceActive
())
||
super
.
hasActions
(
tree
,
element
);
}
public
getActions
(
tree
:
ITree
,
element
:
any
):
TPromise
<
IAction
[]
>
{
return
super
.
getActions
(
tree
,
element
).
then
(
actions
=>
{
let
input
=
<
SearchResult
>
tree
.
getInput
();
if
(
element
instanceof
FileMatch
)
{
actions
.
unshift
(
new
RemoveAction
(
tree
,
element
));
if
(
input
.
searchModel
.
isReplaceActive
()
&&
element
.
count
()
>
0
)
{
actions
.
unshift
(
this
.
instantiationService
.
createInstance
(
ReplaceAllAction
,
tree
,
element
,
this
.
viewlet
));
}
}
if
(
element
instanceof
Match
)
{
if
(
input
.
searchModel
.
isReplaceActive
())
{
actions
.
unshift
(
this
.
instantiationService
.
createInstance
(
ReplaceAction
,
tree
,
element
,
this
.
viewlet
),
new
RemoveAction
(
tree
,
element
));
}
}
return
actions
;
});
}
}
interface
IFileMatchTemplate
{
label
:
FileLabel
;
badge
:
CountBadge
;
actions
:
ActionBar
;
}
interface
IMatchTemplate
{
...
...
@@ -135,6 +105,7 @@ interface IMatchTemplate {
match
:
HTMLElement
;
replace
?:
HTMLElement
;
after
:
HTMLElement
;
actions
:
ActionBar
;
}
export
class
SearchRenderer
extends
Disposable
implements
IRenderer
{
...
...
@@ -142,7 +113,7 @@ export class SearchRenderer extends Disposable implements IRenderer {
private
static
FILE_MATCH_TEMPLATE_ID
=
'
fileMatch
'
;
private
static
MATCH_TEMPLATE_ID
=
'
match
'
;
constructor
(
actionRunner
:
IActionRunner
,
viewlet
:
SearchViewlet
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
constructor
(
actionRunner
:
IActionRunner
,
private
viewlet
:
SearchViewlet
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
();
}
...
...
@@ -174,7 +145,7 @@ export class SearchRenderer extends Disposable implements IRenderer {
public
renderElement
(
tree
:
ITree
,
element
:
any
,
templateId
:
string
,
templateData
:
any
):
void
{
if
(
SearchRenderer
.
FILE_MATCH_TEMPLATE_ID
===
templateId
)
{
this
.
renderFileMatch
(
<
FileMatch
>
element
,
<
IFileMatchTemplate
>
templateData
);
this
.
renderFileMatch
(
tree
,
<
FileMatch
>
element
,
<
IFileMatchTemplate
>
templateData
);
}
else
if
(
SearchRenderer
.
MATCH_TEMPLATE_ID
===
templateId
)
{
this
.
renderMatch
(
tree
,
<
Match
>
element
,
<
IMatchTemplate
>
templateData
);
}
...
...
@@ -185,33 +156,45 @@ export class SearchRenderer extends Disposable implements IRenderer {
let
fileMatchElement
=
DOM
.
append
(
container
,
DOM
.
$
(
'
.filematch
'
));
const
label
=
this
.
instantiationService
.
createInstance
(
FileLabel
,
fileMatchElement
,
void
0
);
const
badge
=
new
CountBadge
(
DOM
.
append
(
fileMatchElement
,
DOM
.
$
(
'
.badge
'
)));
return
{
label
,
badge
};
const
actions
=
new
ActionBar
(
fileMatchElement
,
{
animated
:
false
});
return
{
label
,
badge
,
actions
};
}
private
renderMatchTemplate
(
tree
:
ITree
,
templateId
:
string
,
container
:
HTMLElement
):
IMatchTemplate
{
DOM
.
addClass
(
container
,
'
linematch
'
);
const
parent
=
DOM
.
append
(
container
,
DOM
.
$
(
'
a.plain
'
));
const
parent
=
DOM
.
append
(
container
,
DOM
.
$
(
'
a.plain
.match
'
));
const
before
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
span
'
));
const
match
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
span.findInFileMatch
'
));
const
replace
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
span.replaceMatch
'
));
const
after
=
DOM
.
append
(
parent
,
DOM
.
$
(
'
span
'
));
const
actions
=
new
ActionBar
(
container
,
{
animated
:
false
});
return
{
parent
,
before
,
match
,
replace
,
after
after
,
actions
};
}
private
renderFileMatch
(
fileMatch
:
FileMatch
,
templateData
:
IFileMatchTemplate
):
void
{
private
renderFileMatch
(
tree
:
ITree
,
fileMatch
:
FileMatch
,
templateData
:
IFileMatchTemplate
):
void
{
templateData
.
label
.
setFile
(
fileMatch
.
resource
());
let
count
=
fileMatch
.
count
();
templateData
.
badge
.
setCount
(
count
);
templateData
.
badge
.
setTitleFormat
(
count
>
1
?
nls
.
localize
(
'
searchMatches
'
,
"
{0} matches found
"
,
count
)
:
nls
.
localize
(
'
searchMatch
'
,
"
{0} match found
"
,
count
));
let
input
=
<
SearchResult
>
tree
.
getInput
();
templateData
.
actions
.
clear
();
const
actions
:
IAction
[]
=
[];
if
(
input
.
searchModel
.
isReplaceActive
()
&&
count
>
0
)
{
actions
.
push
(
this
.
instantiationService
.
createInstance
(
ReplaceAllAction
,
tree
,
fileMatch
,
this
.
viewlet
));
}
actions
.
push
(
new
RemoveAction
(
tree
,
fileMatch
));
templateData
.
actions
.
push
(
actions
,
{
icon
:
true
,
label
:
false
});
}
private
renderMatch
(
tree
:
ITree
,
match
:
Match
,
templateData
:
IMatchTemplate
):
void
{
...
...
@@ -225,6 +208,11 @@ export class SearchRenderer extends Disposable implements IRenderer {
templateData
.
replace
.
textContent
=
replace
?
strings
.
escape
(
match
.
replaceString
)
:
''
;
templateData
.
after
.
textContent
=
strings
.
escape
(
preview
.
after
);
templateData
.
parent
.
title
=
(
preview
.
before
+
(
templateData
.
replace
?
match
.
replaceString
:
preview
.
inside
)
+
preview
.
after
).
trim
().
substr
(
0
,
999
);
templateData
.
actions
.
clear
();
if
(
searchModel
.
isReplaceActive
())
{
templateData
.
actions
.
push
([
this
.
instantiationService
.
createInstance
(
ReplaceAction
,
tree
,
match
,
this
.
viewlet
),
new
RemoveAction
(
tree
,
match
)],
{
icon
:
true
,
label
:
false
});
}
}
public
disposeTemplate
(
tree
:
ITree
,
templateId
:
string
,
templateData
:
any
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录