Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
d5dac808
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,发现更多精彩内容 >>
提交
d5dac808
编写于
11月 16, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove event emitter from focus tracker
上级
aac483aa
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
73 addition
and
73 deletion
+73
-73
src/vs/base/browser/dom.ts
src/vs/base/browser/dom.ts
+32
-26
src/vs/base/browser/ui/actionbar/actionbar.ts
src/vs/base/browser/ui/actionbar/actionbar.ts
+3
-3
src/vs/base/browser/ui/splitview/panelview.ts
src/vs/base/browser/ui/splitview/panelview.ts
+2
-2
src/vs/base/parts/tree/browser/treeView.ts
src/vs/base/parts/tree/browser/treeView.ts
+2
-2
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+4
-4
src/vs/editor/contrib/find/findWidget.ts
src/vs/editor/contrib/find/findWidget.ts
+4
-4
src/vs/editor/contrib/find/simpleFindWidget.ts
src/vs/editor/contrib/find/simpleFindWidget.ts
+4
-4
src/vs/workbench/browser/parts/editor/editorGroupsControl.ts
src/vs/workbench/browser/parts/editor/editorGroupsControl.ts
+3
-1
src/vs/workbench/browser/parts/views/panelViewlet.ts
src/vs/workbench/browser/parts/views/panelViewlet.ts
+1
-1
src/vs/workbench/parts/markers/browser/markersPanel.ts
src/vs/workbench/parts/markers/browser/markersPanel.ts
+2
-3
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+2
-2
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+1
-1
src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts
...workbench/parts/preferences/browser/preferencesWidgets.ts
+6
-5
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+1
-1
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+2
-2
src/vs/workbench/parts/search/browser/searchWidget.ts
src/vs/workbench/parts/search/browser/searchWidget.ts
+4
-12
未找到文件。
src/vs/base/browser/dom.ts
浏览文件 @
d5dac808
...
...
@@ -8,13 +8,14 @@ import * as platform from 'vs/base/common/platform';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TimeoutTimer
}
from
'
vs/base/common/async
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
isObject
}
from
'
vs/base/common/types
'
;
import
*
as
browser
from
'
vs/base/browser/browser
'
;
import
{
IKeyboardEvent
,
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
IMouseEvent
,
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
export
function
clearNode
(
node
:
HTMLElement
)
{
while
(
node
.
firstChild
)
{
...
...
@@ -417,12 +418,17 @@ export interface IEventMerger<R, E> {
(
lastEvent
:
R
,
currentEvent
:
E
):
R
;
}
export
interface
DOMEvent
{
preventDefault
():
void
;
stopPropagation
():
void
;
}
const
MINIMUM_TIME_MS
=
16
;
const
DEFAULT_EVENT_MERGER
:
IEventMerger
<
Event
,
Event
>
=
function
(
lastEvent
:
Event
,
currentEvent
:
Event
)
{
const
DEFAULT_EVENT_MERGER
:
IEventMerger
<
DOMEvent
,
DOMEvent
>
=
function
(
lastEvent
:
DOMEvent
,
currentEvent
:
DOM
Event
)
{
return
currentEvent
;
};
class
TimeoutThrottledDomListener
<
R
,
E
extends
Event
>
extends
Disposable
{
class
TimeoutThrottledDomListener
<
R
,
E
extends
DOM
Event
>
extends
Disposable
{
constructor
(
node
:
any
,
type
:
string
,
handler
:
(
event
:
R
)
=>
void
,
eventMerger
:
IEventMerger
<
R
,
E
>
=
<
any
>
DEFAULT_EVENT_MERGER
,
minimumTimeMs
:
number
=
MINIMUM_TIME_MS
)
{
super
();
...
...
@@ -452,7 +458,7 @@ class TimeoutThrottledDomListener<R, E extends Event> extends Disposable {
}
}
export
function
addDisposableThrottledListener
<
R
,
E
extends
Event
=
Event
>
(
node
:
any
,
type
:
string
,
handler
:
(
event
:
R
)
=>
void
,
eventMerger
?:
IEventMerger
<
R
,
E
>
,
minimumTimeMs
?:
number
):
IDisposable
{
export
function
addDisposableThrottledListener
<
R
,
E
extends
DOMEvent
=
DOM
Event
>
(
node
:
any
,
type
:
string
,
handler
:
(
event
:
R
)
=>
void
,
eventMerger
?:
IEventMerger
<
R
,
E
>
,
minimumTimeMs
?:
number
):
IDisposable
{
return
new
TimeoutThrottledDomListener
<
R
,
E
>
(
node
,
type
,
handler
,
eventMerger
,
minimumTimeMs
);
}
...
...
@@ -813,8 +819,8 @@ export const EventHelper = {
};
export
interface
IFocusTracker
{
addBlurListener
(
fn
:
()
=>
void
):
IDisposable
;
addFocusListener
(
fn
:
()
=>
void
):
IDisposable
;
onDidFocus
:
Event
<
void
>
;
onDidBlur
:
Event
<
void
>
;
dispose
():
void
;
}
...
...
@@ -836,49 +842,49 @@ export function restoreParentsScrollTop(node: Element, state: number[]): void {
}
}
class
FocusTracker
extends
Disposable
implements
IFocusTracker
{
class
FocusTracker
implements
IFocusTracker
{
private
_eventEmitter
:
EventEmitter
;
private
_onDidFocus
=
new
Emitter
<
void
>
();
readonly
onDidFocus
:
Event
<
void
>
=
this
.
_onDidFocus
.
event
;
constructor
(
element
:
HTMLElement
|
Window
)
{
super
()
;
private
_onDidBlur
=
new
Emitter
<
void
>
();
readonly
onDidBlur
:
Event
<
void
>
=
this
.
_onDidBlur
.
event
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
element
:
HTMLElement
|
Window
)
{
let
hasFocus
=
false
;
let
loosingFocus
=
false
;
this
.
_eventEmitter
=
this
.
_register
(
new
EventEmitter
());
let
onFocus
=
(
event
:
Event
)
=>
{
let
onFocus
=
()
=>
{
loosingFocus
=
false
;
if
(
!
hasFocus
)
{
hasFocus
=
true
;
this
.
_
eventEmitter
.
emit
(
'
focus
'
,
{}
);
this
.
_
onDidFocus
.
fire
(
);
}
};
let
onBlur
=
(
event
:
Event
)
=>
{
let
onBlur
=
()
=>
{
if
(
hasFocus
)
{
loosingFocus
=
true
;
window
.
setTimeout
(()
=>
{
if
(
loosingFocus
)
{
loosingFocus
=
false
;
hasFocus
=
false
;
this
.
_
eventEmitter
.
emit
(
'
blur
'
,
{}
);
this
.
_
onDidBlur
.
fire
(
);
}
},
0
);
}
};
this
.
_register
(
addDisposableListener
(
element
,
EventType
.
FOCUS
,
onFocus
,
true
));
this
.
_register
(
addDisposableListener
(
element
,
EventType
.
BLUR
,
onBlur
,
true
));
}
public
addFocusListener
(
fn
:
()
=>
void
):
IDisposable
{
return
this
.
_eventEmitter
.
addListener
(
'
focus
'
,
fn
);
domEvent
(
element
,
EventType
.
FOCUS
,
true
)(
onFocus
,
null
,
this
.
disposables
);
domEvent
(
element
,
EventType
.
BLUR
,
true
)(
onBlur
,
null
,
this
.
disposables
);
}
public
addBlurListener
(
fn
:
()
=>
void
):
IDisposable
{
return
this
.
_eventEmitter
.
addListener
(
'
blur
'
,
fn
);
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
_onDidFocus
.
dispose
();
this
.
_onDidBlur
.
dispose
();
}
}
...
...
@@ -1007,7 +1013,7 @@ export function getElementsByTagName(tag: string): HTMLElement[] {
return
Array
.
prototype
.
slice
.
call
(
document
.
getElementsByTagName
(
tag
),
0
);
}
export
function
finalHandler
<
T
extends
Event
>
(
fn
:
(
event
:
T
)
=>
any
):
(
event
:
T
)
=>
any
{
export
function
finalHandler
<
T
extends
DOM
Event
>
(
fn
:
(
event
:
T
)
=>
any
):
(
event
:
T
)
=>
any
{
return
e
=>
{
e
.
preventDefault
();
e
.
stopPropagation
();
...
...
src/vs/base/browser/ui/actionbar/actionbar.ts
浏览文件 @
d5dac808
...
...
@@ -487,14 +487,14 @@ export class ActionBar implements IActionRunner {
});
this
.
focusTracker
=
DOM
.
trackFocus
(
this
.
domNode
);
this
.
focusTracker
.
addBlurListene
r
(()
=>
{
this
.
toDispose
.
push
(
this
.
focusTracker
.
onDidBlu
r
(()
=>
{
if
(
document
.
activeElement
===
this
.
domNode
||
!
DOM
.
isAncestor
(
document
.
activeElement
,
this
.
domNode
))
{
this
.
_onDidBlur
.
fire
();
this
.
focusedItem
=
undefined
;
}
});
})
)
;
this
.
focusTracker
.
addFocusListener
(()
=>
this
.
updateFocusedItem
(
));
this
.
toDispose
.
push
(
this
.
focusTracker
.
onDidFocus
(()
=>
this
.
updateFocusedItem
()
));
this
.
actionsList
=
document
.
createElement
(
'
ul
'
);
this
.
actionsList
.
className
=
'
actions-container
'
;
...
...
src/vs/base/browser/ui/splitview/panelview.ts
浏览文件 @
d5dac808
...
...
@@ -146,8 +146,8 @@ export abstract class Panel implements IView {
this
.
renderHeader
(
this
.
header
);
const
focusTracker
=
trackFocus
(
this
.
header
);
focusTracker
.
addFocusListener
(()
=>
addClass
(
this
.
header
,
'
focused
'
));
focusTracker
.
addBlurListene
r
(()
=>
removeClass
(
this
.
header
,
'
focused
'
));
focusTracker
.
onDidFocus
(()
=>
addClass
(
this
.
header
,
'
focused
'
));
focusTracker
.
onDidBlu
r
(()
=>
removeClass
(
this
.
header
,
'
focused
'
));
this
.
updateHeader
();
...
...
src/vs/base/parts/tree/browser/treeView.ts
浏览文件 @
d5dac808
...
...
@@ -485,8 +485,8 @@ export class TreeView extends HeightMap {
}
var
focusTracker
=
DOM
.
trackFocus
(
this
.
domNode
);
focusTracker
.
addFocusListener
(()
=>
this
.
onFocus
(
));
focusTracker
.
addBlurListener
(()
=>
this
.
onBlur
(
));
this
.
viewListeners
.
push
(
focusTracker
.
onDidFocus
(()
=>
this
.
onFocus
()
));
this
.
viewListeners
.
push
(
focusTracker
.
onDidBlur
(()
=>
this
.
onBlur
()
));
this
.
viewListeners
.
push
(
focusTracker
);
this
.
viewListeners
.
push
(
DOM
.
addDisposableListener
(
this
.
domNode
,
'
keydown
'
,
(
e
)
=>
this
.
onKeyDown
(
e
)));
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
d5dac808
...
...
@@ -468,14 +468,14 @@ class CodeEditorWidgetFocusTracker extends Disposable {
this
.
_hasFocus
=
false
;
this
.
_domFocusTracker
=
this
.
_register
(
dom
.
trackFocus
(
domElement
));
this
.
_
domFocusTracker
.
addFocusListener
(()
=>
{
this
.
_
register
(
this
.
_domFocusTracker
.
onDidFocus
(()
=>
{
this
.
_hasFocus
=
true
;
this
.
_onChange
.
fire
(
void
0
);
});
this
.
_
domFocusTracker
.
addBlurListene
r
(()
=>
{
})
)
;
this
.
_
register
(
this
.
_domFocusTracker
.
onDidBlu
r
(()
=>
{
this
.
_hasFocus
=
false
;
this
.
_onChange
.
fire
(
void
0
);
});
})
)
;
}
public
hasFocus
():
boolean
{
...
...
src/vs/editor/contrib/find/findWidget.ts
浏览文件 @
d5dac808
...
...
@@ -193,7 +193,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
}));
this
.
_findInputFocused
=
CONTEXT_FIND_INPUT_FOCUSED
.
bindTo
(
contextKeyService
);
this
.
_focusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
_findInput
.
inputBox
.
inputElement
));
this
.
_
focusTracker
.
addFocusListener
(()
=>
{
this
.
_
register
(
this
.
_focusTracker
.
onDidFocus
(()
=>
{
this
.
_findInputFocused
.
set
(
true
);
if
(
this
.
_toggleSelectionFind
.
checked
)
{
...
...
@@ -209,10 +209,10 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
}
}
}
});
this
.
_
focusTracker
.
addBlurListene
r
(()
=>
{
})
)
;
this
.
_
register
(
this
.
_focusTracker
.
onDidBlu
r
(()
=>
{
this
.
_findInputFocused
.
set
(
false
);
});
})
)
;
this
.
_codeEditor
.
addOverlayWidget
(
this
);
this
.
_viewZone
=
new
FindWidgetViewZone
(
0
);
// Put it before the first line then users can scroll beyond the first line.
...
...
src/vs/editor/contrib/find/simpleFindWidget.ts
浏览文件 @
d5dac808
...
...
@@ -113,12 +113,12 @@ export abstract class SimpleFindWidget extends Widget {
});
this
.
_focusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
_innerDomNode
));
this
.
_register
(
this
.
_focusTracker
.
addFocusListener
(
this
.
onFocusTrackerFocus
.
bind
(
this
)));
this
.
_register
(
this
.
_focusTracker
.
addBlurListene
r
(
this
.
onFocusTrackerBlur
.
bind
(
this
)));
this
.
_register
(
this
.
_focusTracker
.
onDidFocus
(
this
.
onFocusTrackerFocus
.
bind
(
this
)));
this
.
_register
(
this
.
_focusTracker
.
onDidBlu
r
(
this
.
onFocusTrackerBlur
.
bind
(
this
)));
this
.
_findInputFocusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
_findInput
.
domNode
));
this
.
_register
(
this
.
_findInputFocusTracker
.
addFocusListener
(
this
.
onFindInputFocusTrackerFocus
.
bind
(
this
)));
this
.
_register
(
this
.
_findInputFocusTracker
.
addBlurListene
r
(
this
.
onFindInputFocusTrackerBlur
.
bind
(
this
)));
this
.
_register
(
this
.
_findInputFocusTracker
.
onDidFocus
(
this
.
onFindInputFocusTrackerFocus
.
bind
(
this
)));
this
.
_register
(
this
.
_findInputFocusTracker
.
onDidBlu
r
(
this
.
onFindInputFocusTrackerBlur
.
bind
(
this
)));
this
.
_register
(
dom
.
addDisposableListener
(
this
.
_innerDomNode
,
'
click
'
,
(
event
)
=>
{
event
.
stopPropagation
();
...
...
src/vs/workbench/browser/parts/editor/editorGroupsControl.ts
浏览文件 @
d5dac808
...
...
@@ -424,7 +424,9 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
// Track focus on editor container
this
.
visibleEditorFocusTrackers
[
position
]
=
DOM
.
trackFocus
(
editor
.
getContainer
().
getHTMLElement
());
this
.
visibleEditorFocusTrackers
[
position
].
addFocusListener
(()
=>
{
// TODO@ben: when is this listener disposed?
this
.
visibleEditorFocusTrackers
[
position
].
onDidFocus
(()
=>
{
this
.
onFocusGained
(
editor
);
});
}
...
...
src/vs/workbench/browser/parts/views/panelViewlet.ts
浏览文件 @
d5dac808
...
...
@@ -70,7 +70,7 @@ export abstract class ViewletPanel extends Panel {
const
focusTracker
=
trackFocus
(
container
);
this
.
disposables
.
push
(
focusTracker
);
this
.
disposables
.
push
(
focusTracker
.
addFocusListener
(()
=>
this
.
_onDidFocus
.
fire
()));
this
.
disposables
.
push
(
focusTracker
.
onDidFocus
(()
=>
this
.
_onDidFocus
.
fire
()));
}
protected
renderHeader
(
container
:
HTMLElement
):
void
{
...
...
src/vs/workbench/parts/markers/browser/markersPanel.ts
浏览文件 @
d5dac808
...
...
@@ -227,9 +227,8 @@ export class MarkersPanel extends Panel {
}));
const
focusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
tree
.
getHTMLElement
()));
focusTracker
.
addBlurListener
(()
=>
{
this
.
markerFocusContextKey
.
set
(
false
);
});
this
.
_register
(
focusTracker
.
onDidBlur
(()
=>
this
.
markerFocusContextKey
.
set
(
false
)));
this
.
_register
(
focusTracker
);
this
.
toUnbind
.
push
(
this
.
listService
.
register
(
this
.
tree
));
}
...
...
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
d5dac808
...
...
@@ -132,8 +132,8 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
this
.
createBody
(
keybindingsEditorElement
);
const
focusTracker
=
this
.
_register
(
DOM
.
trackFocus
(
parentElement
));
this
.
_register
(
focusTracker
.
addFocusListener
(()
=>
this
.
keybindingsEditorContextKey
.
set
(
true
)));
this
.
_register
(
focusTracker
.
addBlurListene
r
(()
=>
this
.
keybindingsEditorContextKey
.
reset
()));
this
.
_register
(
focusTracker
.
onDidFocus
(()
=>
this
.
keybindingsEditorContextKey
.
set
(
true
)));
this
.
_register
(
focusTracker
.
onDidBlu
r
(()
=>
this
.
keybindingsEditorContextKey
.
reset
()));
}
setInput
(
input
:
KeybindingsEditorInput
):
TPromise
<
void
>
{
...
...
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
d5dac808
...
...
@@ -662,7 +662,7 @@ class SideBySidePreferencesWidget extends Widget {
}));
const
focusTracker
=
this
.
_register
(
DOM
.
trackFocus
(
parentElement
));
this
.
_register
(
focusTracker
.
addFocusListener
(()
=>
this
.
_onFocus
.
fire
()));
this
.
_register
(
focusTracker
.
onDidFocus
(()
=>
this
.
_onFocus
.
fire
()));
}
public
setInput
(
defaultPreferencesEditorInput
:
DefaultPreferencesEditorInput
,
editablePreferencesEditorInput
:
EditorInput
,
options
?:
EditorOptions
):
TPromise
<
{
defaultPreferencesRenderer
:
IPreferencesRenderer
<
ISetting
>
,
editablePreferencesRenderer
:
IPreferencesRenderer
<
ISetting
>
}
>
{
...
...
src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts
浏览文件 @
d5dac808
...
...
@@ -179,8 +179,9 @@ export class SettingsGroupTitleWidget extends Widget implements IViewZone {
this
.
onclick
(
this
.
titleContainer
,
()
=>
this
.
toggle
());
this
.
onkeydown
(
this
.
titleContainer
,
(
e
)
=>
this
.
onKeyDown
(
e
));
const
focusTracker
=
this
.
_register
(
DOM
.
trackFocus
(
this
.
titleContainer
));
focusTracker
.
addFocusListener
(()
=>
this
.
toggleFocus
(
true
));
focusTracker
.
addBlurListener
(()
=>
this
.
toggleFocus
(
false
));
this
.
_register
(
focusTracker
.
onDidFocus
(()
=>
this
.
toggleFocus
(
true
)));
this
.
_register
(
focusTracker
.
onDidBlur
(()
=>
this
.
toggleFocus
(
false
)));
this
.
icon
=
DOM
.
append
(
this
.
titleContainer
,
DOM
.
$
(
'
.expand-collapse-icon
'
));
this
.
title
=
DOM
.
append
(
this
.
titleContainer
,
DOM
.
$
(
'
.title
'
));
...
...
@@ -499,11 +500,11 @@ export class SearchWidget extends Widget {
this
.
inputBox
.
inputElement
.
setAttribute
(
'
aria-live
'
,
'
assertive
'
);
const
focusTracker
=
this
.
_register
(
DOM
.
trackFocus
(
this
.
inputBox
.
inputElement
));
this
.
_register
(
focusTracker
.
addFocusListener
(()
=>
this
.
_onFocus
.
fire
()));
this
.
_register
(
focusTracker
.
onDidFocus
(()
=>
this
.
_onFocus
.
fire
()));
if
(
this
.
options
.
focusKey
)
{
this
.
_register
(
focusTracker
.
addFocusListener
(()
=>
this
.
options
.
focusKey
.
set
(
true
)));
this
.
_register
(
focusTracker
.
addBlurListene
r
(()
=>
this
.
options
.
focusKey
.
set
(
false
)));
this
.
_register
(
focusTracker
.
onDidFocus
(()
=>
this
.
options
.
focusKey
.
set
(
true
)));
this
.
_register
(
focusTracker
.
onDidBlu
r
(()
=>
this
.
options
.
focusKey
.
set
(
false
)));
}
}
...
...
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
d5dac808
...
...
@@ -561,7 +561,7 @@ export class RepositoryPanel extends ViewletPanel {
protected
renderBody
(
container
:
HTMLElement
):
void
{
const
focusTracker
=
trackFocus
(
container
);
this
.
disposables
.
push
(
focusTracker
.
addFocusListener
(()
=>
this
.
repository
.
focus
()));
this
.
disposables
.
push
(
focusTracker
.
onDidFocus
(()
=>
this
.
repository
.
focus
()));
this
.
disposables
.
push
(
focusTracker
);
// Input
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
d5dac808
...
...
@@ -317,13 +317,13 @@ export class SearchViewlet extends Viewlet {
}
private
trackInputBox
(
inputFocusTracker
:
dom
.
IFocusTracker
,
contextKey
?:
IContextKey
<
boolean
>
):
void
{
this
.
toUnbind
.
push
(
inputFocusTracker
.
addFocusListener
(()
=>
{
this
.
toUnbind
.
push
(
inputFocusTracker
.
onDidFocus
(()
=>
{
this
.
inputBoxFocused
.
set
(
true
);
if
(
contextKey
)
{
contextKey
.
set
(
true
);
}
}));
this
.
toUnbind
.
push
(
inputFocusTracker
.
addBlurListene
r
(()
=>
{
this
.
toUnbind
.
push
(
inputFocusTracker
.
onDidBlu
r
(()
=>
{
this
.
inputBoxFocused
.
set
(
this
.
searchWidget
.
searchInputHasFocus
()
||
this
.
searchWidget
.
replaceInputHasFocus
()
||
this
.
inputPatternIncludes
.
inputHasFocus
()
...
...
src/vs/workbench/parts/search/browser/searchWidget.ts
浏览文件 @
d5dac808
...
...
@@ -241,12 +241,8 @@ export class SearchWidget extends Widget {
}));
this
.
searchInputFocusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
searchInput
.
inputBox
.
inputElement
));
this
.
_register
(
this
.
searchInputFocusTracker
.
addFocusListener
(()
=>
{
this
.
searchInputBoxFocused
.
set
(
true
);
}));
this
.
_register
(
this
.
searchInputFocusTracker
.
addBlurListener
(()
=>
{
this
.
searchInputBoxFocused
.
set
(
false
);
}));
this
.
_register
(
this
.
searchInputFocusTracker
.
onDidFocus
(()
=>
this
.
searchInputBoxFocused
.
set
(
true
)));
this
.
_register
(
this
.
searchInputFocusTracker
.
onDidBlur
(()
=>
this
.
searchInputBoxFocused
.
set
(
false
)));
}
private
renderReplaceInput
(
parent
:
HTMLElement
):
void
{
...
...
@@ -268,12 +264,8 @@ export class SearchWidget extends Widget {
this
.
replaceActionBar
.
push
([
this
.
replaceAllAction
],
{
icon
:
true
,
label
:
false
});
this
.
replaceInputFocusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
replaceInput
.
inputElement
));
this
.
_register
(
this
.
replaceInputFocusTracker
.
addFocusListener
(()
=>
{
this
.
replaceInputBoxFocused
.
set
(
true
);
}));
this
.
_register
(
this
.
replaceInputFocusTracker
.
addBlurListener
(()
=>
{
this
.
replaceInputBoxFocused
.
set
(
false
);
}));
this
.
_register
(
this
.
replaceInputFocusTracker
.
onDidFocus
(()
=>
this
.
replaceInputBoxFocused
.
set
(
true
)));
this
.
_register
(
this
.
replaceInputFocusTracker
.
onDidBlur
(()
=>
this
.
replaceInputBoxFocused
.
set
(
false
)));
}
triggerReplaceAll
():
TPromise
<
any
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录