Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
dda38cab
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,发现更多精彩内容 >>
未验证
提交
dda38cab
编写于
11月 07, 2019
作者:
J
Jackson Kearl
提交者:
GitHub
11月 07, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make pattern inputs also trigger as you type (#84148)
上级
99baecd8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
21 deletion
+35
-21
src/vs/workbench/contrib/search/browser/patternInputWidget.ts
...vs/workbench/contrib/search/browser/patternInputWidget.ts
+28
-7
src/vs/workbench/contrib/search/browser/searchView.ts
src/vs/workbench/contrib/search/browser/searchView.ts
+2
-2
src/vs/workbench/contrib/search/browser/searchWidget.ts
src/vs/workbench/contrib/search/browser/searchWidget.ts
+5
-12
未找到文件。
src/vs/workbench/contrib/search/browser/patternInputWidget.ts
浏览文件 @
dda38cab
...
...
@@ -16,6 +16,9 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import
{
attachInputBoxStyler
,
attachCheckboxStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
ContextScopedHistoryInputBox
}
from
'
vs/platform/browser/contextScopedHistoryWidget
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ISearchConfigurationProperties
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
Delayer
}
from
'
vs/base/common/async
'
;
export
interface
IOptions
{
placeholder
?:
string
;
...
...
@@ -23,6 +26,8 @@ export interface IOptions {
validation
?:
IInputValidator
;
ariaLabel
?:
string
;
history
?:
string
[];
submitOnType
?:
boolean
;
submitOnTypeDelay
?:
number
;
}
export
class
PatternInputWidget
extends
Widget
{
...
...
@@ -38,14 +43,17 @@ export class PatternInputWidget extends Widget {
private
domNode
!
:
HTMLElement
;
protected
inputBox
!
:
HistoryInputBox
;
private
_onSubmit
=
this
.
_register
(
new
Emitter
<
boolean
>
());
onSubmit
:
CommonEvent
<
boolean
>
=
this
.
_onSubmit
.
event
;
private
_onSubmit
=
this
.
_register
(
new
Emitter
<
void
>
());
onSubmit
:
CommonEvent
<
void
>
=
this
.
_onSubmit
.
event
;
private
_onCancel
=
this
.
_register
(
new
Emitter
<
boolean
>
());
onCancel
:
CommonEvent
<
boolean
>
=
this
.
_onCancel
.
event
;
private
_onCancel
=
this
.
_register
(
new
Emitter
<
void
>
());
onCancel
:
CommonEvent
<
void
>
=
this
.
_onCancel
.
event
;
private
searchOnTypeDelayer
:
Delayer
<
void
>
;
constructor
(
parent
:
HTMLElement
,
private
contextViewProvider
:
IContextViewProvider
,
options
:
IOptions
=
Object
.
create
(
null
),
@
IThemeService
protected
themeService
:
IThemeService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
)
{
super
();
...
...
@@ -53,6 +61,8 @@ export class PatternInputWidget extends Widget {
this
.
placeholder
=
options
.
placeholder
||
''
;
this
.
ariaLabel
=
options
.
ariaLabel
||
nls
.
localize
(
'
defaultLabel
'
,
"
input
"
);
this
.
_register
(
this
.
searchOnTypeDelayer
=
new
Delayer
(
this
.
searchConfig
.
searchOnTypeDebouncePeriod
));
this
.
render
(
options
);
parent
.
appendChild
(
this
.
domNode
);
...
...
@@ -139,6 +149,12 @@ export class PatternInputWidget extends Widget {
this
.
_register
(
attachInputBoxStyler
(
this
.
inputBox
,
this
.
themeService
));
this
.
inputFocusTracker
=
dom
.
trackFocus
(
this
.
inputBox
.
inputElement
);
this
.
onkeyup
(
this
.
inputBox
.
inputElement
,
(
keyboardEvent
)
=>
this
.
onInputKeyUp
(
keyboardEvent
));
this
.
_register
(
this
.
inputBox
.
onDidChange
(()
=>
{
if
(
this
.
searchConfig
.
searchOnType
)
{
this
.
_onCancel
.
fire
();
this
.
searchOnTypeDelayer
.
trigger
(()
=>
this
.
_onSubmit
.
fire
(),
this
.
searchConfig
.
searchOnTypeDebouncePeriod
);
}
}));
const
controls
=
document
.
createElement
(
'
div
'
);
controls
.
className
=
'
controls
'
;
...
...
@@ -154,15 +170,19 @@ export class PatternInputWidget extends Widget {
private
onInputKeyUp
(
keyboardEvent
:
IKeyboardEvent
)
{
switch
(
keyboardEvent
.
keyCode
)
{
case
KeyCode
.
Enter
:
this
.
_onSubmit
.
fire
(
false
);
this
.
_onSubmit
.
fire
();
return
;
case
KeyCode
.
Escape
:
this
.
_onCancel
.
fire
(
false
);
this
.
_onCancel
.
fire
();
return
;
default
:
return
;
}
}
get
searchConfig
()
{
return
this
.
configurationService
.
getValue
<
ISearchConfigurationProperties
>
(
'
search
'
);
}
}
export
class
ExcludePatternInputWidget
extends
PatternInputWidget
{
...
...
@@ -172,9 +192,10 @@ export class ExcludePatternInputWidget extends PatternInputWidget {
constructor
(
parent
:
HTMLElement
,
contextViewProvider
:
IContextViewProvider
,
options
:
IOptions
=
Object
.
create
(
null
),
@
IThemeService
themeService
:
IThemeService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
(
parent
,
contextViewProvider
,
options
,
themeService
,
contextKeyService
);
super
(
parent
,
contextViewProvider
,
options
,
themeService
,
con
figurationService
,
con
textKeyService
);
}
private
useExcludesAndIgnoreFilesBox
!
:
Checkbox
;
...
...
src/vs/workbench/contrib/search/browser/searchView.ts
浏览文件 @
dda38cab
...
...
@@ -268,7 +268,7 @@ export class SearchView extends ViewletPanel {
this
.
inputPatternIncludes
.
setValue
(
patternIncludes
);
this
.
inputPatternIncludes
.
onSubmit
(()
=>
this
.
onQueryChanged
(
true
));
this
.
inputPatternIncludes
.
onCancel
(()
=>
this
.
viewModel
.
cancelSearch
());
// Cancel search without focusing the search widget
this
.
inputPatternIncludes
.
onCancel
(()
=>
this
.
cancelSearch
(
false
));
this
.
trackInputBox
(
this
.
inputPatternIncludes
.
inputFocusTracker
,
this
.
inputPatternIncludesFocused
);
// excludes list
...
...
@@ -284,7 +284,7 @@ export class SearchView extends ViewletPanel {
this
.
inputPatternExcludes
.
setUseExcludesAndIgnoreFiles
(
useExcludesAndIgnoreFiles
);
this
.
inputPatternExcludes
.
onSubmit
(()
=>
this
.
onQueryChanged
(
true
));
this
.
inputPatternExcludes
.
onCancel
(()
=>
this
.
viewModel
.
cancelSearch
());
// Cancel search without focusing the search widget
this
.
inputPatternExcludes
.
onCancel
(()
=>
this
.
cancelSearch
(
false
));
this
.
inputPatternExcludes
.
onChangeIgnoreBox
(()
=>
this
.
onQueryChanged
(
true
));
this
.
trackInputBox
(
this
.
inputPatternExcludes
.
inputFocusTracker
,
this
.
inputPatternExclusionsFocused
);
...
...
src/vs/workbench/contrib/search/browser/searchWidget.ts
浏览文件 @
dda38cab
...
...
@@ -448,6 +448,11 @@ export class SearchWidget extends Widget {
private
onSearchInputChanged
():
void
{
this
.
searchInput
.
clearMessage
();
this
.
setReplaceAllActionState
(
false
);
if
(
this
.
searchConfiguration
.
searchOnType
)
{
this
.
_onSearchCancel
.
fire
({
focus
:
false
});
this
.
_searchDelayer
.
trigger
((()
=>
this
.
submitSearch
()),
this
.
searchConfiguration
.
searchOnTypeDebouncePeriod
);
}
}
private
onSearchInputKeyDown
(
keyboardEvent
:
IKeyboardEvent
)
{
...
...
@@ -482,18 +487,6 @@ export class SearchWidget extends Widget {
else
if
(
keyboardEvent
.
equals
(
KeyCode
.
DownArrow
))
{
stopPropagationForMultiLineDownwards
(
keyboardEvent
,
this
.
searchInput
.
getValue
(),
this
.
searchInput
.
domNode
.
querySelector
(
'
textarea
'
));
}
if
((
keyboardEvent
.
browserEvent
.
key
.
length
===
1
&&
!
(
keyboardEvent
.
ctrlKey
||
keyboardEvent
.
metaKey
)
||
keyboardEvent
.
equals
(
KeyCode
.
Backspace
)
||
keyboardEvent
.
equals
(
KeyCode
.
UpArrow
)
||
keyboardEvent
.
equals
(
KeyCode
.
DownArrow
))
&&
this
.
searchConfiguration
.
searchOnType
)
{
// Check to see if this input changes the query, being either a printable key (`key` is length 1, and not modified), or backspace, or history scroll
// If so, trigger a new search eventually, and preemptively cancel the old one as it's results will soon be discarded anyways.
this
.
_onSearchCancel
.
fire
({
focus
:
false
});
this
.
_searchDelayer
.
trigger
((()
=>
this
.
submitSearch
()));
}
}
private
onCaseSensitiveKeyDown
(
keyboardEvent
:
IKeyboardEvent
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录