Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8d666f34
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,发现更多精彩内容 >>
提交
8d666f34
编写于
5月 29, 2017
作者:
R
Ryan Stringham
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add history navigation for file includes and excludes patterns in the search viewlet
上级
1070a6a8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
158 addition
and
3 deletion
+158
-3
src/vs/workbench/parts/search/browser/patternInputWidget.ts
src/vs/workbench/parts/search/browser/patternInputWidget.ts
+31
-0
src/vs/workbench/parts/search/browser/search.contribution.ts
src/vs/workbench/parts/search/browser/search.contribution.ts
+40
-0
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+64
-0
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+21
-3
src/vs/workbench/parts/search/common/constants.ts
src/vs/workbench/parts/search/common/constants.ts
+2
-0
未找到文件。
src/vs/workbench/parts/search/browser/patternInputWidget.ts
浏览文件 @
8d666f34
...
...
@@ -20,6 +20,7 @@ import CommonEvent, { Emitter } from 'vs/base/common/event';
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
attachInputBoxStyler
,
attachCheckboxStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
HistoryNavigator
}
from
'
vs/base/common/history
'
;
export
interface
IOptions
{
placeholder
?:
string
;
...
...
@@ -45,11 +46,14 @@ export class PatternInputWidget extends Widget {
private
inputNode
:
HTMLInputElement
;
protected
inputBox
:
InputBox
;
private
history
:
HistoryNavigator
<
string
>
;
private
_onSubmit
=
this
.
_register
(
new
Emitter
<
boolean
>
());
public
onSubmit
:
CommonEvent
<
boolean
>
=
this
.
_onSubmit
.
event
;
constructor
(
parent
:
HTMLElement
,
private
contextViewProvider
:
IContextViewProvider
,
protected
themeService
:
IThemeService
,
options
:
IOptions
=
Object
.
create
(
null
))
{
super
();
this
.
history
=
new
HistoryNavigator
<
string
>
();
this
.
onOptionChange
=
null
;
this
.
width
=
options
.
width
||
100
;
this
.
placeholder
=
options
.
placeholder
||
''
;
...
...
@@ -185,6 +189,26 @@ export class PatternInputWidget extends Widget {
return
this
.
pattern
.
width
();
}
public
showNextTerm
()
{
let
next
=
this
.
history
.
next
();
if
(
next
)
{
this
.
setValue
(
next
);
}
}
public
showPreviousTerm
()
{
let
previous
;
if
(
this
.
getValue
().
length
===
0
)
{
previous
=
this
.
history
.
current
();
}
else
{
this
.
history
.
addIfNotPresent
(
this
.
getValue
());
previous
=
this
.
history
.
previous
();
}
if
(
previous
)
{
this
.
setValue
(
previous
);
}
}
private
render
():
void
{
this
.
domNode
=
document
.
createElement
(
'
div
'
);
this
.
domNode
.
style
.
width
=
this
.
width
+
'
px
'
;
...
...
@@ -221,6 +245,13 @@ export class PatternInputWidget extends Widget {
});
this
.
_register
(
attachCheckboxStyler
(
this
.
pattern
,
this
.
themeService
));
this
.
_register
(
this
.
onSubmit
(()
=>
{
let
value
=
this
.
getValue
();
if
(
value
.
length
>
0
)
{
this
.
history
.
add
(
this
.
getValue
());
}
}));
$
(
this
.
pattern
.
domNode
).
on
(
'
mouseover
'
,
()
=>
{
if
(
this
.
isGlobPattern
())
{
this
.
showGlobHelp
();
...
...
src/vs/workbench/parts/search/browser/search.contribution.ts
浏览文件 @
8d666f34
...
...
@@ -140,6 +140,46 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
searchActions
.
ShowNextSearchIncludeAction
.
ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
ContextKeyExpr
.
and
(
Constants
.
SearchViewletVisibleKey
,
Constants
.
PatternIncludesFocussedKey
),
primary
:
ShowNextFindTermKeybinding
.
primary
,
handler
:
(
accessor
,
args
:
any
)
=>
{
accessor
.
get
(
IInstantiationService
).
createInstance
(
searchActions
.
ShowNextSearchIncludeAction
,
searchActions
.
ShowNextSearchIncludeAction
.
ID
,
''
).
run
();
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
searchActions
.
ShowPreviousSearchIncludeAction
.
ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
ContextKeyExpr
.
and
(
Constants
.
SearchViewletVisibleKey
,
Constants
.
PatternIncludesFocussedKey
),
primary
:
ShowPreviousFindTermKeybinding
.
primary
,
handler
:
(
accessor
,
args
:
any
)
=>
{
accessor
.
get
(
IInstantiationService
).
createInstance
(
searchActions
.
ShowPreviousSearchIncludeAction
,
searchActions
.
ShowPreviousSearchIncludeAction
.
ID
,
''
).
run
();
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
searchActions
.
ShowNextSearchExcludeAction
.
ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
ContextKeyExpr
.
and
(
Constants
.
SearchViewletVisibleKey
,
Constants
.
PatternExcludesFocussedKey
),
primary
:
ShowNextFindTermKeybinding
.
primary
,
handler
:
(
accessor
,
args
:
any
)
=>
{
accessor
.
get
(
IInstantiationService
).
createInstance
(
searchActions
.
ShowNextSearchExcludeAction
,
searchActions
.
ShowNextSearchExcludeAction
.
ID
,
''
).
run
();
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
searchActions
.
ShowPreviousSearchExcludeAction
.
ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
ContextKeyExpr
.
and
(
Constants
.
SearchViewletVisibleKey
,
Constants
.
PatternExcludesFocussedKey
),
primary
:
ShowPreviousFindTermKeybinding
.
primary
,
handler
:
(
accessor
,
args
:
any
)
=>
{
accessor
.
get
(
IInstantiationService
).
createInstance
(
searchActions
.
ShowPreviousSearchExcludeAction
,
searchActions
.
ShowPreviousSearchExcludeAction
.
ID
,
''
).
run
();
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
searchActions
.
ShowNextSearchTermAction
.
ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
...
...
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
8d666f34
...
...
@@ -88,6 +88,70 @@ export class ToggleRegexAction extends Action {
}
}
export
class
ShowNextSearchIncludeAction
extends
Action
{
public
static
ID
=
'
search.history.showNextIncludePattern
'
;
public
static
LABEL
=
nls
.
localize
(
'
nextSearchIncludePattern
'
,
"
Show Next Search Include Pattern
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IViewletService
private
viewletService
:
IViewletService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
any
>
{
let
searchAndReplaceWidget
=
(
<
SearchViewlet
>
this
.
viewletService
.
getActiveViewlet
()).
searchIncludePattern
;
searchAndReplaceWidget
.
showNextTerm
();
return
TPromise
.
as
(
null
);
}
}
export
class
ShowPreviousSearchIncludeAction
extends
Action
{
public
static
ID
=
'
search.history.showPreviousIncludePattern
'
;
public
static
LABEL
=
nls
.
localize
(
'
previousSearchIncludePattern
'
,
"
Show Previous Search Include Pattern
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IViewletService
private
viewletService
:
IViewletService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
any
>
{
let
searchAndReplaceWidget
=
(
<
SearchViewlet
>
this
.
viewletService
.
getActiveViewlet
()).
searchIncludePattern
;
searchAndReplaceWidget
.
showPreviousTerm
();
return
TPromise
.
as
(
null
);
}
}
export
class
ShowNextSearchExcludeAction
extends
Action
{
public
static
ID
=
'
search.history.showNextExcludePattern
'
;
public
static
LABEL
=
nls
.
localize
(
'
nextSearchExcludePattern
'
,
"
Show Next Search Exclude Pattern
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IViewletService
private
viewletService
:
IViewletService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
any
>
{
let
searchAndReplaceWidget
=
(
<
SearchViewlet
>
this
.
viewletService
.
getActiveViewlet
()).
searchExcludePattern
;
searchAndReplaceWidget
.
showNextTerm
();
return
TPromise
.
as
(
null
);
}
}
export
class
ShowPreviousSearchExcludeAction
extends
Action
{
public
static
ID
=
'
search.history.showPreviousExcludePattern
'
;
public
static
LABEL
=
nls
.
localize
(
'
previousSearchExcludePattern
'
,
"
Show Previous Search Exclude Pattern
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IViewletService
private
viewletService
:
IViewletService
)
{
super
(
id
,
label
);
}
public
run
():
TPromise
<
any
>
{
let
searchAndReplaceWidget
=
(
<
SearchViewlet
>
this
.
viewletService
.
getActiveViewlet
()).
searchExcludePattern
;
searchAndReplaceWidget
.
showPreviousTerm
();
return
TPromise
.
as
(
null
);
}
}
export
class
ShowNextSearchTermAction
extends
Action
{
public
static
ID
=
'
search.history.showNext
'
;
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
8d666f34
...
...
@@ -78,6 +78,8 @@ export class SearchViewlet extends Viewlet {
private
viewletVisible
:
IContextKey
<
boolean
>
;
private
inputBoxFocussed
:
IContextKey
<
boolean
>
;
private
inputPatternIncludesFocussed
:
IContextKey
<
boolean
>
;
private
inputPatternExclusionsFocussed
:
IContextKey
<
boolean
>
;
private
firstMatchFocussed
:
IContextKey
<
boolean
>
;
private
fileMatchOrMatchFocussed
:
IContextKey
<
boolean
>
;
private
fileMatchFocussed
:
IContextKey
<
boolean
>
;
...
...
@@ -129,6 +131,8 @@ export class SearchViewlet extends Viewlet {
this
.
toDispose
=
[];
this
.
viewletVisible
=
Constants
.
SearchViewletVisibleKey
.
bindTo
(
contextKeyService
);
this
.
inputBoxFocussed
=
Constants
.
InputBoxFocussedKey
.
bindTo
(
this
.
contextKeyService
);
this
.
inputPatternIncludesFocussed
=
Constants
.
PatternIncludesFocussedKey
.
bindTo
(
this
.
contextKeyService
);
this
.
inputPatternExclusionsFocussed
=
Constants
.
PatternExcludesFocussedKey
.
bindTo
(
this
.
contextKeyService
);
this
.
firstMatchFocussed
=
Constants
.
FirstMatchFocusKey
.
bindTo
(
contextKeyService
);
this
.
fileMatchOrMatchFocussed
=
Constants
.
FileMatchOrMatchFocusKey
.
bindTo
(
contextKeyService
);
this
.
fileMatchFocussed
=
Constants
.
FileFocusKey
.
bindTo
(
contextKeyService
);
...
...
@@ -217,7 +221,7 @@ export class SearchViewlet extends Viewlet {
});
this
.
inputPatternIncludes
.
onSubmit
(()
=>
this
.
onQueryChanged
(
true
,
true
));
this
.
trackInputBox
(
this
.
inputPatternIncludes
.
inputFocusTracker
);
this
.
trackInputBox
(
this
.
inputPatternIncludes
.
inputFocusTracker
,
this
.
inputPatternIncludesFocussed
);
});
//pattern exclusion list
...
...
@@ -240,7 +244,7 @@ export class SearchViewlet extends Viewlet {
});
this
.
inputPatternExclusions
.
onSubmit
(()
=>
this
.
onQueryChanged
(
true
,
true
));
this
.
trackInputBox
(
this
.
inputPatternExclusions
.
inputFocusTracker
);
this
.
trackInputBox
(
this
.
inputPatternExclusions
.
inputFocusTracker
,
this
.
inputPatternExclusionsFocussed
);
});
// add hint if we have global exclusion
...
...
@@ -288,6 +292,14 @@ export class SearchViewlet extends Viewlet {
return
this
.
searchWidget
;
}
public
get
searchIncludePattern
():
PatternInputWidget
{
return
this
.
inputPatternIncludes
;
}
public
get
searchExcludePattern
():
PatternInputWidget
{
return
this
.
inputPatternExclusions
;
}
private
createSearchWidget
(
builder
:
Builder
):
void
{
let
contentPattern
=
this
.
viewletSettings
[
'
query.contentPattern
'
]
||
''
;
let
isRegex
=
this
.
viewletSettings
[
'
query.regex
'
]
===
true
;
...
...
@@ -326,15 +338,21 @@ export class SearchViewlet extends Viewlet {
this
.
trackInputBox
(
this
.
searchWidget
.
replaceInputFocusTracker
);
}
private
trackInputBox
(
inputFocusTracker
:
dom
.
IFocusTracker
):
void
{
private
trackInputBox
(
inputFocusTracker
:
dom
.
IFocusTracker
,
contextKey
?:
IContextKey
<
boolean
>
):
void
{
this
.
toUnbind
.
push
(
inputFocusTracker
.
addFocusListener
(()
=>
{
this
.
inputBoxFocussed
.
set
(
true
);
if
(
contextKey
)
{
contextKey
.
set
(
true
);
}
}));
this
.
toUnbind
.
push
(
inputFocusTracker
.
addBlurListener
(()
=>
{
this
.
inputBoxFocussed
.
set
(
this
.
searchWidget
.
searchInputHasFocus
()
||
this
.
searchWidget
.
replaceInputHasFocus
()
||
this
.
inputPatternIncludes
.
inputHasFocus
()
||
this
.
inputPatternExclusions
.
inputHasFocus
());
if
(
contextKey
)
{
contextKey
.
set
(
false
);
}
}));
}
...
...
src/vs/workbench/parts/search/common/constants.ts
浏览文件 @
8d666f34
...
...
@@ -25,6 +25,8 @@ export const SearchViewletVisibleKey = new RawContextKey<boolean>('searchViewlet
export
const
InputBoxFocussedKey
=
new
RawContextKey
<
boolean
>
(
'
inputBoxFocus
'
,
false
);
export
const
SearchInputBoxFocussedKey
=
new
RawContextKey
<
boolean
>
(
'
searchInputBoxFocus
'
,
false
);
export
const
ReplaceInputBoxFocussedKey
=
new
RawContextKey
<
boolean
>
(
'
replaceInputBoxFocus
'
,
false
);
export
const
PatternIncludesFocussedKey
=
new
RawContextKey
<
boolean
>
(
'
patternIncludesInputBoxFocus
'
,
false
);
export
const
PatternExcludesFocussedKey
=
new
RawContextKey
<
boolean
>
(
'
patternExcludesInputBoxFocus
'
,
false
);
export
const
ReplaceActiveKey
=
new
RawContextKey
<
boolean
>
(
'
replaceActive
'
,
false
);
export
const
FirstMatchFocusKey
=
new
RawContextKey
<
boolean
>
(
'
firstMatchFocus
'
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录