Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
95835bfd
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,发现更多精彩内容 >>
提交
95835bfd
编写于
6月 01, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify EditorEvent
上级
ec4d50c2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
24 deletion
+24
-24
src/vs/workbench/browser/parts/editor/baseEditor.ts
src/vs/workbench/browser/parts/editor/baseEditor.ts
+1
-1
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+11
-11
src/vs/workbench/browser/parts/editor/textEditor.ts
src/vs/workbench/browser/parts/editor/textEditor.ts
+5
-5
src/vs/workbench/common/events.ts
src/vs/workbench/common/events.ts
+4
-4
src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts
.../workbench/test/browser/parts/quickOpen/quickopen.test.ts
+1
-1
src/vs/workbench/test/common/events.test.ts
src/vs/workbench/test/common/events.test.ts
+2
-2
未找到文件。
src/vs/workbench/browser/parts/editor/baseEditor.ts
浏览文件 @
95835bfd
...
...
@@ -123,7 +123,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
*/
public
changePosition
(
position
:
Position
):
void
{
this
.
_position
=
position
;
this
.
emit
(
EventType
.
EDITOR_POSITION_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
this
.
options
,
this
.
position
));
this
.
emit
(
EventType
.
EDITOR_POSITION_CHANGED
,
new
EditorEvent
(
this
,
this
.
input
,
this
.
options
,
this
.
position
));
}
/**
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
95835bfd
...
...
@@ -163,7 +163,7 @@ export class EditorPart extends Part implements IEditorPart {
}
// Emit early open event to allow for veto
let
event
=
new
EditorEvent
(
null
,
null
,
input
,
options
,
position
);
let
event
=
new
EditorEvent
(
null
,
input
,
options
,
position
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_OPENING
,
event
);
if
(
event
.
isPrevented
())
{
return
TPromise
.
as
<
BaseEditor
>
(
null
);
...
...
@@ -263,7 +263,7 @@ export class EditorPart extends Part implements IEditorPart {
this
.
sideBySideControl
.
layout
(
position
);
// Emit Editor-Opened Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_OPENED
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_OPENED
,
new
EditorEvent
(
editor
,
input
,
options
,
position
));
timerEvent
.
stop
();
...
...
@@ -369,7 +369,7 @@ export class EditorPart extends Part implements IEditorPart {
const
previousInput
=
editor
.
getInput
();
const
inputChanged
=
(
!
previousInput
||
!
previousInput
.
matches
(
input
)
||
(
options
&&
options
.
forceOpen
));
if
(
inputChanged
)
{
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
editor
,
input
,
options
,
position
));
}
// Call into Editor
...
...
@@ -394,7 +394,7 @@ export class EditorPart extends Part implements IEditorPart {
// editor title area is up to date.
if
(
group
.
activeEditor
&&
group
.
activeEditor
.
matches
(
input
))
{
this
.
doRecreateEditorTitleArea
();
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
group
.
activeEditor
,
options
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
editor
,
group
.
activeEditor
,
options
,
position
));
}
return
editor
;
...
...
@@ -411,7 +411,7 @@ export class EditorPart extends Part implements IEditorPart {
// Emit Input-Changed Event (if input changed)
if
(
inputChanged
)
{
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
editor
,
input
,
options
,
position
));
}
// Update Title Area
...
...
@@ -452,7 +452,7 @@ export class EditorPart extends Part implements IEditorPart {
this
.
sideBySideControl
.
updateProgress
(
position
,
ProgressState
.
DONE
);
// Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_SET_INPUT_ERROR
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
input
,
options
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_SET_INPUT_ERROR
,
new
EditorEvent
(
editor
,
input
,
options
,
position
));
// Recover by closing the active editor (if the input is still the active one)
if
(
group
.
activeEditor
===
input
)
{
...
...
@@ -524,13 +524,13 @@ export class EditorPart extends Part implements IEditorPart {
this
.
modifyGroups
(()
=>
this
.
stacks
.
closeGroup
(
group
));
// Emit Input-Changing Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
null
,
null
,
null
,
null
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
null
,
null
,
null
,
position
));
// Hide Editor
this
.
doHideEditor
(
position
,
true
);
// Emit Input-Changed Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
null
,
null
,
null
,
null
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
null
,
null
,
null
,
position
));
// Focus next group if we have an active one left
const
currentActiveGroup
=
this
.
stacks
.
activeGroup
;
...
...
@@ -570,7 +570,7 @@ export class EditorPart extends Part implements IEditorPart {
this
.
sideBySideControl
.
clearTitleArea
(
position
);
// Emit Editor Closed Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_CLOSED
,
new
EditorEvent
(
editor
,
editor
.
getId
(),
null
,
null
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_CLOSED
,
new
EditorEvent
(
editor
,
null
,
null
,
position
));
}
public
closeAllEditors
(
except
?:
Position
):
TPromise
<
void
>
{
...
...
@@ -812,8 +812,8 @@ export class EditorPart extends Part implements IEditorPart {
// Emit as editor input change event so that clients get aware of new active editor
let
activeEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
if
(
activeEditor
)
{
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
getId
(),
activeEditor
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
getId
(),
activeEditor
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
input
,
null
,
activeEditor
.
position
));
}
// Update Title Area
...
...
src/vs/workbench/browser/parts/editor/textEditor.ts
浏览文件 @
95835bfd
...
...
@@ -136,27 +136,27 @@ export abstract class BaseTextEditor extends BaseEditor {
// Hook Listener for Selection changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidChangeCursorPosition
((
event
:
ICursorPositionChangedEvent
)
=>
{
let
selection
=
this
.
editorControl
.
getSelection
();
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_SELECTION_CHANGED
,
new
TextEditorSelectionEvent
(
selection
,
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_SELECTION_CHANGED
,
new
TextEditorSelectionEvent
(
selection
,
this
,
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for mode changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidChangeModelMode
((
event
:
IModelModeChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_MODE_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_MODE_CHANGED
,
new
EditorEvent
(
this
,
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for content changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidChangeModelRawContent
((
event
:
IModelContentChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONTENT_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONTENT_CHANGED
,
new
EditorEvent
(
this
,
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for content options changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidChangeModelOptions
((
event
:
IModelOptionsChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONTENT_OPTIONS_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONTENT_OPTIONS_CHANGED
,
new
EditorEvent
(
this
,
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for options changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidChangeConfiguration
((
event
:
IConfigurationChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONFIGURATION_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONFIGURATION_CHANGED
,
new
EditorEvent
(
this
,
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Configuration
...
...
src/vs/workbench/common/events.ts
浏览文件 @
95835bfd
...
...
@@ -136,11 +136,11 @@ export class EditorEvent extends Event {
private
prevented
:
boolean
;
constructor
(
editor
:
IEditor
,
editorI
d
:
string
,
editorI
nput
:
IEditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
constructor
(
editor
:
IEditor
,
editorInput
:
IEditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
super
(
originalEvent
);
this
.
editor
=
editor
;
this
.
editorId
=
editor
Id
;
this
.
editorId
=
editor
?
editor
.
getId
()
:
void
0
;
this
.
editorInput
=
editorInput
;
this
.
editorOptions
=
editorOptions
;
this
.
position
=
position
;
...
...
@@ -161,8 +161,8 @@ export class EditorEvent extends Event {
export
class
TextEditorSelectionEvent
extends
EditorEvent
{
public
selection
:
Selection
;
constructor
(
selection
:
Selection
,
editor
:
IEditor
,
editorI
d
:
string
,
editorI
nput
:
IEditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
super
(
editor
,
editorI
d
,
editorI
nput
,
editorOptions
,
position
,
originalEvent
);
constructor
(
selection
:
Selection
,
editor
:
IEditor
,
editorInput
:
IEditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
super
(
editor
,
editorInput
,
editorOptions
,
position
,
originalEvent
);
this
.
selection
=
selection
;
}
...
...
src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts
浏览文件 @
95835bfd
...
...
@@ -240,7 +240,7 @@ suite('Workbench QuickOpen', () => {
assert
.
equal
(
0
,
controller
.
getEditorHistoryModel
().
getEntries
().
length
);
let
cinput1
=
<
EditorInput
>
inst
.
createInstance
(
fileInputCtor
,
toResource
(
'
Hello World
'
),
'
text/plain
'
,
null
);
let
event
=
new
EditorEvent
(
null
,
''
,
cinput1
,
null
,
Position
.
LEFT
);
let
event
=
new
EditorEvent
(
null
,
cinput1
,
null
,
Position
.
LEFT
);
eventService
.
emit
(
EventType
.
EDITOR_INPUT_CHANGING
,
event
);
assert
.
equal
(
1
,
controller
.
getEditorHistoryModel
().
getEntries
().
length
);
...
...
src/vs/workbench/test/common/events.test.ts
浏览文件 @
95835bfd
...
...
@@ -25,12 +25,12 @@ suite('Workbench Events', () => {
});
test
(
'
Editor Change Event
'
,
function
()
{
let
editor
:
any
=
{};
let
editor
:
any
=
{
getId
:
()
=>
'
foo.bar
'
};
let
origEvent
:
any
=
{};
let
input
:
any
=
{};
let
options
:
any
=
{};
let
id
=
'
foo.bar
'
;
let
event
=
new
EditorEvent
(
editor
,
i
d
,
i
nput
,
options
,
0
,
origEvent
);
let
event
=
new
EditorEvent
(
editor
,
input
,
options
,
0
,
origEvent
);
assert
.
strictEqual
(
event
.
editor
,
editor
);
assert
.
strictEqual
(
event
.
originalEvent
,
origEvent
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录