Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e434c070
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,体验更适合开发者的 AI 搜索 >>
提交
e434c070
编写于
4月 11, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes Microsoft/monaco-editor#806: Emit focus/blur events only when the state changes
上级
7187c21a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
20 deletion
+44
-20
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+4
-10
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+40
-10
未找到文件。
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
e434c070
...
@@ -101,13 +101,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
...
@@ -101,13 +101,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
this
.
_focusTracker
=
new
CodeEditorWidgetFocusTracker
(
domElement
);
this
.
_focusTracker
=
new
CodeEditorWidgetFocusTracker
(
domElement
);
this
.
_focusTracker
.
onChange
(()
=>
{
this
.
_focusTracker
.
onChange
(()
=>
{
let
hasFocus
=
this
.
_focusTracker
.
hasFocus
();
this
.
_editorFocus
.
setValue
(
this
.
_focusTracker
.
hasFocus
());
if
(
hasFocus
)
{
this
.
_onDidFocusEditor
.
fire
();
}
else
{
this
.
_onDidBlurEditor
.
fire
();
}
});
});
this
.
contentWidgets
=
{};
this
.
contentWidgets
=
{};
...
@@ -431,13 +425,13 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
...
@@ -431,13 +425,13 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
const
viewEventBus
=
this
.
_view
.
getInternalEventBus
();
const
viewEventBus
=
this
.
_view
.
getInternalEventBus
();
viewEventBus
.
onDidGainFocus
=
()
=>
{
viewEventBus
.
onDidGainFocus
=
()
=>
{
this
.
_
onDidFocusEditorText
.
fire
(
);
this
.
_
editorTextFocus
.
setValue
(
true
);
// In IE, the focus is not synchronous, so we give it a little help
// In IE, the focus is not synchronous, so we give it a little help
this
.
_
onDidFocusEditor
.
fire
(
);
this
.
_
editorFocus
.
setValue
(
true
);
};
};
viewEventBus
.
onDidScroll
=
(
e
)
=>
this
.
_onDidScrollChange
.
fire
(
e
);
viewEventBus
.
onDidScroll
=
(
e
)
=>
this
.
_onDidScrollChange
.
fire
(
e
);
viewEventBus
.
onDidLoseFocus
=
()
=>
this
.
_
onDidBlurEditorText
.
fire
(
);
viewEventBus
.
onDidLoseFocus
=
()
=>
this
.
_
editorTextFocus
.
setValue
(
false
);
viewEventBus
.
onContextMenu
=
(
e
)
=>
this
.
_onContextMenu
.
fire
(
e
);
viewEventBus
.
onContextMenu
=
(
e
)
=>
this
.
_onContextMenu
.
fire
(
e
);
viewEventBus
.
onMouseDown
=
(
e
)
=>
this
.
_onMouseDown
.
fire
(
e
);
viewEventBus
.
onMouseDown
=
(
e
)
=>
this
.
_onMouseDown
.
fire
(
e
);
viewEventBus
.
onMouseUp
=
(
e
)
=>
this
.
_onMouseUp
.
fire
(
e
);
viewEventBus
.
onMouseUp
=
(
e
)
=>
this
.
_onMouseUp
.
fire
(
e
);
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
e434c070
...
@@ -68,17 +68,13 @@ export abstract class CommonCodeEditor extends Disposable {
...
@@ -68,17 +68,13 @@ export abstract class CommonCodeEditor extends Disposable {
private
readonly
_onDidLayoutChange
:
Emitter
<
editorOptions
.
EditorLayoutInfo
>
=
this
.
_register
(
new
Emitter
<
editorOptions
.
EditorLayoutInfo
>
());
private
readonly
_onDidLayoutChange
:
Emitter
<
editorOptions
.
EditorLayoutInfo
>
=
this
.
_register
(
new
Emitter
<
editorOptions
.
EditorLayoutInfo
>
());
public
readonly
onDidLayoutChange
:
Event
<
editorOptions
.
EditorLayoutInfo
>
=
this
.
_onDidLayoutChange
.
event
;
public
readonly
onDidLayoutChange
:
Event
<
editorOptions
.
EditorLayoutInfo
>
=
this
.
_onDidLayoutChange
.
event
;
protected
readonly
_onDidFocusEditorText
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
protected
_editorTextFocus
:
BooleanEventEmitter
=
this
.
_register
(
new
BooleanEventEmitter
());
public
readonly
onDidFocusEditorText
:
Event
<
void
>
=
this
.
_onDidFocusEditorText
.
event
;
public
readonly
onDidFocusEditorText
:
Event
<
void
>
=
this
.
_editorTextFocus
.
onDidChangeToTrue
;
public
readonly
onDidBlurEditorText
:
Event
<
void
>
=
this
.
_editorTextFocus
.
onDidChangeToFalse
;
protected
readonly
_onDidBlurEditorText
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
protected
_editorFocus
:
BooleanEventEmitter
=
this
.
_register
(
new
BooleanEventEmitter
());
public
readonly
onDidBlurEditorText
:
Event
<
void
>
=
this
.
_onDidBlurEditorText
.
event
;
public
readonly
onDidFocusEditor
:
Event
<
void
>
=
this
.
_editorFocus
.
onDidChangeToTrue
;
public
readonly
onDidBlurEditor
:
Event
<
void
>
=
this
.
_editorFocus
.
onDidChangeToFalse
;
protected
readonly
_onDidFocusEditor
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidFocusEditor
:
Event
<
void
>
=
this
.
_onDidFocusEditor
.
event
;
protected
readonly
_onDidBlurEditor
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidBlurEditor
:
Event
<
void
>
=
this
.
_onDidBlurEditor
.
event
;
private
readonly
_onWillType
:
Emitter
<
string
>
=
this
.
_register
(
new
Emitter
<
string
>
());
private
readonly
_onWillType
:
Emitter
<
string
>
=
this
.
_register
(
new
Emitter
<
string
>
());
public
readonly
onWillType
=
this
.
_onWillType
.
event
;
public
readonly
onWillType
=
this
.
_onWillType
.
event
;
...
@@ -1047,6 +1043,40 @@ export abstract class CommonCodeEditor extends Disposable {
...
@@ -1047,6 +1043,40 @@ export abstract class CommonCodeEditor extends Disposable {
}
}
}
}
const
enum
BooleanEventValue
{
NotSet
,
False
,
True
}
export
class
BooleanEventEmitter
extends
Disposable
{
private
readonly
_onDidChangeToTrue
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidChangeToTrue
:
Event
<
void
>
=
this
.
_onDidChangeToTrue
.
event
;
private
readonly
_onDidChangeToFalse
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidChangeToFalse
:
Event
<
void
>
=
this
.
_onDidChangeToFalse
.
event
;
private
_value
:
BooleanEventValue
;
constructor
()
{
super
();
this
.
_value
=
BooleanEventValue
.
NotSet
;
}
public
setValue
(
_value
:
boolean
)
{
let
value
=
(
_value
?
BooleanEventValue
.
True
:
BooleanEventValue
.
False
);
if
(
this
.
_value
===
value
)
{
return
;
}
this
.
_value
=
value
;
if
(
this
.
_value
===
BooleanEventValue
.
True
)
{
this
.
_onDidChangeToTrue
.
fire
();
}
else
if
(
this
.
_value
===
BooleanEventValue
.
False
)
{
this
.
_onDidChangeToFalse
.
fire
();
}
}
}
class
EditorContextKeysManager
extends
Disposable
{
class
EditorContextKeysManager
extends
Disposable
{
private
_editor
:
CommonCodeEditor
;
private
_editor
:
CommonCodeEditor
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录