Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f1abc274
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,发现更多精彩内容 >>
提交
f1abc274
编写于
2月 01, 2017
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #19199 - debounce F4/Shift+F4
上级
ddad50c5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
10 deletion
+35
-10
src/vs/base/common/event.ts
src/vs/base/common/event.ts
+8
-3
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+2
-2
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+25
-5
未找到文件。
src/vs/base/common/event.ts
浏览文件 @
f1abc274
...
...
@@ -305,9 +305,9 @@ export function any<T>(...events: Event<T>[]): Event<T> {
return
emitter
.
event
;
}
export
function
debounceEvent
<
T
>
(
event
:
Event
<
T
>
,
merger
:
(
last
:
T
,
event
:
T
)
=>
T
,
delay
?:
number
):
Event
<
T
>
;
export
function
debounceEvent
<
I
,
O
>
(
event
:
Event
<
I
>
,
merger
:
(
last
:
O
,
event
:
I
)
=>
O
,
delay
?:
number
):
Event
<
O
>
;
export
function
debounceEvent
<
I
,
O
>
(
event
:
Event
<
I
>
,
merger
:
(
last
:
O
,
event
:
I
)
=>
O
,
delay
:
number
=
100
):
Event
<
O
>
{
export
function
debounceEvent
<
T
>
(
event
:
Event
<
T
>
,
merger
:
(
last
:
T
,
event
:
T
)
=>
T
,
delay
?:
number
,
leading
?:
boolean
):
Event
<
T
>
;
export
function
debounceEvent
<
I
,
O
>
(
event
:
Event
<
I
>
,
merger
:
(
last
:
O
,
event
:
I
)
=>
O
,
delay
?:
number
,
leading
?:
boolean
):
Event
<
O
>
;
export
function
debounceEvent
<
I
,
O
>
(
event
:
Event
<
I
>
,
merger
:
(
last
:
O
,
event
:
I
)
=>
O
,
delay
:
number
=
100
,
leading
=
false
):
Event
<
O
>
{
let
subscription
:
IDisposable
;
let
output
:
O
;
...
...
@@ -317,11 +317,16 @@ export function debounceEvent<I, O>(event: Event<I>, merger: (last: O, event: I)
onFirstListenerAdd
()
{
subscription
=
event
(
cur
=>
{
output
=
merger
(
output
,
cur
);
if
(
!
handle
&&
leading
)
{
emitter
.
fire
(
output
);
}
clearTimeout
(
handle
);
handle
=
setTimeout
(()
=>
{
let
_output
=
output
;
output
=
undefined
;
emitter
.
fire
(
_output
);
handle
=
null
;
},
delay
);
});
},
...
...
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
f1abc274
...
...
@@ -276,7 +276,7 @@ export class FocusNextSearchResultAction extends Action {
public
run
():
TPromise
<
any
>
{
return
this
.
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
).
then
((
searchViewlet
:
SearchViewlet
)
=>
{
searchViewlet
.
selectNext
Result
();
searchViewlet
.
selectNext
Match
();
});
}
}
...
...
@@ -291,7 +291,7 @@ export class FocusPreviousSearchResultAction extends Action {
public
run
():
TPromise
<
any
>
{
return
this
.
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
).
then
((
searchViewlet
:
SearchViewlet
)
=>
{
searchViewlet
.
selectPrevious
Result
();
searchViewlet
.
selectPrevious
Match
();
});
}
}
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
f1abc274
...
...
@@ -8,6 +8,7 @@
import
'
vs/css!./media/searchviewlet
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Emitter
,
debounceEvent
}
from
'
vs/base/common/event
'
;
import
{
EditorType
,
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
errors
=
require
(
'
vs/base/common/errors
'
);
...
...
@@ -88,6 +89,8 @@ export class SearchViewlet extends Viewlet {
private
currentSelectedFileMatch
:
FileMatch
;
private
selectCurrentMatchEmitter
:
Emitter
<
string
>
;
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IFileService
private
fileService
:
IFileService
,
...
...
@@ -121,6 +124,10 @@ export class SearchViewlet extends Viewlet {
this
.
toUnbind
.
push
(
this
.
untitledEditorService
.
onDidChangeDirty
(
e
=>
this
.
onUntitledDidChangeDirty
(
e
)));
this
.
toUnbind
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationUpdated
(
e
.
config
)));
this
.
selectCurrentMatchEmitter
=
new
Emitter
<
string
>
();
debounceEvent
(
this
.
selectCurrentMatchEmitter
.
event
,
(
l
,
e
)
=>
e
,
100
,
/*leading=*/
true
)
(()
=>
this
.
selectCurrentMatch
());
}
private
onConfigurationUpdated
(
configuration
:
any
):
void
{
...
...
@@ -481,7 +488,10 @@ export class SearchViewlet extends Viewlet {
}
this
.
currentSelectedFileMatch
=
selectedMatch
.
parent
();
this
.
currentSelectedFileMatch
.
setSelectedMatch
(
selectedMatch
);
this
.
onFocus
(
selectedMatch
,
!
focusEditor
,
sideBySide
,
doubleClick
);
if
(
!
event
.
payload
.
preventEditorOpen
)
{
this
.
onFocus
(
selectedMatch
,
!
focusEditor
,
sideBySide
,
doubleClick
);
}
}
}));
});
...
...
@@ -511,8 +521,13 @@ export class SearchViewlet extends Viewlet {
}
}
public
selectNextResult
():
void
{
public
selectCurrentMatch
():
void
{
const
focused
=
this
.
tree
.
getFocus
();
const
eventPayload
=
{
focusEditor
:
true
};
this
.
tree
.
setSelection
([
focused
],
eventPayload
);
}
public
selectNextMatch
():
void
{
const
[
selected
]:
FileMatchOrMatch
[]
=
this
.
tree
.
getSelection
();
const
navigator
=
this
.
tree
.
getNavigator
(
selected
,
/*subTreeOnly=*/
false
);
let
next
=
navigator
.
next
();
...
...
@@ -532,13 +547,14 @@ export class SearchViewlet extends Viewlet {
}
// Reveal the newly selected element
const
eventPayload
=
{
preventEditorOpen
:
true
};
this
.
tree
.
setFocus
(
next
,
eventPayload
);
this
.
tree
.
setSelection
([
next
],
eventPayload
);
this
.
tree
.
reveal
(
next
);
this
.
selectCurrentMatchEmitter
.
fire
();
}
public
selectPreviousResult
():
void
{
const
eventPayload
=
{
focusEditor
:
true
};
public
selectPreviousMatch
():
void
{
const
[
selected
]:
FileMatchOrMatch
[]
=
this
.
tree
.
getSelection
();
const
navigator
=
this
.
tree
.
getNavigator
(
selected
,
/*subTreeOnly=*/
false
);
...
...
@@ -561,9 +577,11 @@ export class SearchViewlet extends Viewlet {
// Reveal the newly selected element
if
(
prev
)
{
const
eventPayload
=
{
preventEditorOpen
:
true
};
this
.
tree
.
setFocus
(
prev
,
eventPayload
);
this
.
tree
.
setSelection
([
prev
],
eventPayload
);
this
.
tree
.
reveal
(
prev
);
this
.
selectCurrentMatchEmitter
.
fire
();
}
}
...
...
@@ -1136,7 +1154,9 @@ export class SearchViewlet extends Viewlet {
this
.
telemetryService
.
publicLog
(
'
searchResultChosen
'
);
return
(
this
.
viewModel
.
isReplaceActive
()
&&
!!
this
.
viewModel
.
replaceString
)
?
this
.
replaceService
.
openReplacePreview
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
)
:
this
.
open
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
);
return
(
this
.
viewModel
.
isReplaceActive
()
&&
!!
this
.
viewModel
.
replaceString
)
?
this
.
replaceService
.
openReplacePreview
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
)
:
this
.
open
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
);
}
public
open
(
element
:
FileMatchOrMatch
,
preserveFocus
?:
boolean
,
sideBySide
?:
boolean
,
pinned
?:
boolean
):
TPromise
<
any
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录