Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6989497e
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,发现更多精彩内容 >>
提交
6989497e
编写于
6月 01, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more editor events clean up
上级
0b7dd3ea
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
83 addition
and
52 deletion
+83
-52
src/vs/workbench/browser/layout.ts
src/vs/workbench/browser/layout.ts
+2
-2
src/vs/workbench/browser/parts/editor/baseEditor.ts
src/vs/workbench/browser/parts/editor/baseEditor.ts
+2
-2
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+7
-7
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
.../workbench/browser/parts/quickopen/quickOpenController.ts
+4
-6
src/vs/workbench/common/events.ts
src/vs/workbench/common/events.ts
+51
-19
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+2
-2
src/vs/workbench/services/progress/browser/progressService.ts
...vs/workbench/services/progress/browser/progressService.ts
+6
-5
src/vs/workbench/test/browser/services.test.ts
src/vs/workbench/test/browser/services.test.ts
+9
-9
未找到文件。
src/vs/workbench/browser/layout.ts
浏览文件 @
6989497e
...
...
@@ -121,7 +121,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
this
.
panelHeight
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashYHeightSettingsKey
,
StorageScope
.
GLOBAL
,
0
);
this
.
toUnbind
.
push
(
themeService
.
onDidThemeChange
(
_
=>
this
.
relayout
()));
this
.
toUnbind
.
push
(
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGING
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanging
(
e
)));
this
.
toUnbind
.
push
(
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGING
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanging
()));
this
.
registerSashListeners
();
}
...
...
@@ -243,7 +243,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
});
}
private
onEditorInputChanging
(
e
:
EditorEvent
):
void
{
private
onEditorInputChanging
():
void
{
// Make sure that we layout properly in case we detect that the sidebar is large enought to cause
// multiple opened editors to go below minimal size. The fix is to trigger a layout for any editor
...
...
src/vs/workbench/browser/parts/editor/baseEditor.ts
浏览文件 @
6989497e
...
...
@@ -9,7 +9,7 @@ import {Action, IAction} from 'vs/base/common/actions';
import
{
ActionBarContributor
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
Builder
}
from
'
vs/base/browser/builder
'
;
import
{
EventType
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
}
from
'
vs/workbench/common/events
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
Panel
}
from
'
vs/workbench/browser/panel
'
;
import
{
EditorInput
,
IFileEditorInput
,
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
...
...
@@ -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
.
input
,
this
.
options
,
this
.
position
)
);
this
.
emit
(
EventType
.
EDITOR_POSITION_CHANGED
,
this
);
}
/**
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
6989497e
...
...
@@ -21,7 +21,7 @@ import errors = require('vs/base/common/errors');
import
{
Scope
as
MementoScope
}
from
'
vs/workbench/common/memento
'
;
import
{
Scope
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
import
{
EventType
as
WorkbenchEventType
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
,
EditorEvent
,
EditorInputEvent
}
from
'
vs/workbench/common/events
'
;
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
,
BaseEditor
,
EditorDescriptor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorInput
,
EditorOptions
,
TextEditorOptions
,
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
...
...
@@ -163,7 +163,7 @@ export class EditorPart extends Part implements IEditorPart {
}
// Emit early open event to allow for veto
let
event
=
new
Editor
Event
(
null
,
input
,
options
,
position
);
let
event
=
new
Editor
InputEvent
(
input
);
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
,
input
,
options
,
position
)
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_OPENED
,
editor
);
timerEvent
.
stop
();
...
...
@@ -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
Editor
Event
(
editor
,
input
,
options
,
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_SET_INPUT_ERROR
,
new
Editor
InputEvent
(
input
));
// Recover by closing the active editor (if the input is still the active one)
if
(
group
.
activeEditor
===
input
)
{
...
...
@@ -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
,
null
,
null
,
position
)
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_CLOSED
,
editor
);
}
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
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
activeEditor
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
activeEditor
));
}
// Update Title Area
...
...
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
浏览文件 @
6989497e
...
...
@@ -20,7 +20,7 @@ import {ContributableActionProvider} from 'vs/workbench/browser/actionBarRegistr
import
{
ITree
,
IElementCallback
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
WorkbenchComponent
}
from
'
vs/workbench/common/component
'
;
import
{
EditorEvent
,
EventType
}
from
'
vs/workbench/common/events
'
;
import
{
EditorEvent
,
E
ditorInputEvent
,
E
ventType
}
from
'
vs/workbench/common/events
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Identifiers
}
from
'
vs/workbench/common/constants
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -125,7 +125,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
// Listen on Editor Input Changes to show in MRU List
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGING
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanging
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_SET_INPUT_ERROR
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputSetError
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_SET_INPUT_ERROR
,
(
e
:
Editor
Input
Event
)
=>
this
.
onEditorInputSetError
(
e
)));
// Editor History Model
this
.
editorHistoryModel
=
new
EditorHistoryModel
(
this
.
editorService
,
this
.
instantiationService
,
this
.
contextService
);
...
...
@@ -155,10 +155,8 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
}
}
private
onEditorInputSetError
(
e
:
EditorEvent
):
void
{
if
(
e
.
editorInput
)
{
this
.
removeEditorHistoryEntry
(
e
.
editorInput
);
// make sure this input does not show up in history if it failed to open
}
private
onEditorInputSetError
(
e
:
EditorInputEvent
):
void
{
this
.
removeEditorHistoryEntry
(
e
.
editorInput
);
// make sure this input does not show up in history if it failed to open
}
public
getEditorHistory
():
IEditorInput
[]
{
...
...
src/vs/workbench/common/events.ts
浏览文件 @
6989497e
...
...
@@ -6,8 +6,7 @@
import
URI
from
'
vs/base/common/uri
'
;
import
{
Event
}
from
'
vs/base/common/events
'
;
import
{
IEditor
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditor
,
IEditorInput
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
/**
...
...
@@ -98,26 +97,18 @@ export class EventType {
static
WORKBENCH_OPTIONS_CHANGED
=
'
workbenchOptionsChanged
'
;
}
/**
* Editor events are being emitted when the editor input changes, shows, is being saved or when the editor content changes.
*/
export
class
EditorEvent
extends
Event
{
public
editor
:
IEditor
;
public
editorId
:
string
;
public
editorInput
:
IEditorInput
;
public
editorOptions
:
EditorOptions
;
public
position
:
Position
;
export
class
EditorInputEvent
extends
Event
{
private
_editorInput
:
IEditorInput
;
private
prevented
:
boolean
;
constructor
(
editor
:
IEditor
,
editorInput
:
IEditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
super
(
originalEvent
);
constructor
(
editorInput
:
IEditorInput
)
{
super
(
null
);
this
.
_editorInput
=
editorInput
;
}
this
.
editor
=
editor
;
this
.
editorId
=
editor
?
editor
.
getId
()
:
void
0
;
this
.
editorInput
=
editorInput
;
this
.
editorOptions
=
editorOptions
;
this
.
position
=
position
;
public
get
editorInput
():
IEditorInput
{
return
this
.
_editorInput
;
}
public
prevent
():
void
{
...
...
@@ -129,6 +120,47 @@ export class EditorEvent extends Event {
}
}
/**
* Editor events are being emitted when the editor input changes, shows, is being saved or when the editor content changes.
*/
export
class
EditorEvent
extends
Event
{
private
_editor
:
IEditor
;
private
_editorId
:
string
;
private
_editorInput
:
IEditorInput
;
private
_editorOptions
:
IEditorOptions
;
private
_position
:
Position
;
constructor
(
editor
:
IEditor
,
editorInput
=
editor
.
input
,
editorOptions
=
editor
.
options
,
position
=
editor
.
position
,
originalEvent
?:
any
)
{
super
(
originalEvent
);
this
.
_editor
=
editor
;
this
.
_editorId
=
editor
?
editor
.
getId
()
:
void
0
;
this
.
_editorInput
=
editorInput
;
this
.
_editorOptions
=
editorOptions
;
this
.
_position
=
position
;
}
public
get
editor
():
IEditor
{
return
this
.
_editor
;
}
public
get
editorId
():
string
{
return
this
.
_editorId
;
}
public
get
editorInput
():
IEditorInput
{
return
this
.
_editorInput
;
}
public
get
editorOptions
():
IEditorOptions
{
return
this
.
_editorOptions
;
}
public
get
position
():
Position
{
return
this
.
_position
;
}
}
/**
* Option change events are send when the options in the running instance change.
*/
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
6989497e
...
...
@@ -24,7 +24,7 @@ import {Action, IAction} from 'vs/base/common/actions';
import
{
MessageType
,
IInputValidator
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
ITree
,
IHighlightEvent
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
EventType
as
WorkbenchEventType
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
,
Editor
Input
Event
}
from
'
vs/workbench/common/events
'
;
import
{
LocalFileChangeEvent
,
VIEWLET_ID
,
ITextFileService
,
TextFileChangeEvent
,
EventType
as
FileEventType
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFileService
,
IFileStat
,
IImportResult
}
from
'
vs/platform/files/common/files
'
;
import
{
DiffEditorInput
,
toDiffLabel
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
...
...
@@ -1227,7 +1227,7 @@ export class GlobalCompareResourcesAction extends Action {
globalResourceToCompare
=
fileInput
.
getResource
();
// Listen for next editor to open
let
unbind
=
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_OPENING
,
(
e
:
EditorEvent
)
=>
{
let
unbind
=
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_OPENING
,
(
e
:
Editor
Input
Event
)
=>
{
unbind
.
dispose
();
// listen once
let
otherFileInput
=
asFileEditorInput
(
e
.
editorInput
);
...
...
src/vs/workbench/services/progress/browser/progressService.ts
浏览文件 @
6989497e
...
...
@@ -7,9 +7,10 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
ProgressBar
}
from
'
vs/base/browser/ui/progressbar/progressbar
'
;
import
{
E
ditorEvent
,
E
ventType
,
CompositeEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
,
CompositeEvent
}
from
'
vs/workbench/common/events
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IProgressService
,
IProgressRunner
}
from
'
vs/platform/progress/common/progress
'
;
import
{
IEditor
}
from
'
vs/platform/editor/common/editor
'
;
interface
ProgressState
{
infinite
?:
boolean
;
...
...
@@ -35,14 +36,14 @@ export abstract class ScopedService {
}
public
registerListeners
():
void
{
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_CLOSED
,
(
e
:
EditorEvent
)
=>
{
if
(
e
.
editorId
===
this
.
scopeId
)
{
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_CLOSED
,
(
e
ditor
:
IEditor
)
=>
{
if
(
e
ditor
.
getId
()
===
this
.
scopeId
)
{
this
.
onScopeDeactivated
();
}
});
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_OPENED
,
(
e
:
EditorEvent
)
=>
{
if
(
e
.
editorId
===
this
.
scopeId
)
{
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_OPENED
,
(
e
ditor
:
IEditor
)
=>
{
if
(
e
ditor
.
getId
()
===
this
.
scopeId
)
{
this
.
onScopeActivated
();
}
});
...
...
src/vs/workbench/test/browser/services.test.ts
浏览文件 @
6989497e
...
...
@@ -426,13 +426,13 @@ suite('Workbench UI Services', () => {
let
service
=
new
TestScopedService
(
eventService
);
assert
(
!
service
.
isActive
);
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
editorId
:
'
other.test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
getId
:
()
=>
'
other.test.scopeId
'
});
assert
(
!
service
.
isActive
);
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
getId
:
()
=>
'
test.scopeId
'
});
assert
(
service
.
isActive
);
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
getId
:
()
=>
'
test.scopeId
'
});
assert
(
!
service
.
isActive
);
eventService
.
emit
(
EventType
.
COMPOSITE_OPENED
,
{
compositeId
:
'
test.scopeId
'
});
...
...
@@ -465,19 +465,19 @@ suite('Workbench UI Services', () => {
assert
.
strictEqual
(
true
,
testProgressBar
.
fDone
);
// Inactive: Show (Infinite)
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
getId
:
()
=>
'
test.scopeId
'
});
service
.
show
(
true
);
assert
.
strictEqual
(
false
,
!!
testProgressBar
.
fInfinite
);
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
getId
:
()
=>
'
test.scopeId
'
});
assert
.
strictEqual
(
true
,
testProgressBar
.
fInfinite
);
// Inactive: Show (Total / Worked)
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
getId
:
()
=>
'
test.scopeId
'
});
fn
=
service
.
show
(
100
);
fn
.
total
(
80
);
fn
.
worked
(
20
);
assert
.
strictEqual
(
false
,
!!
testProgressBar
.
fTotal
);
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
getId
:
()
=>
'
test.scopeId
'
});
assert
.
strictEqual
(
20
,
testProgressBar
.
fWorked
);
assert
.
strictEqual
(
80
,
testProgressBar
.
fTotal
);
...
...
@@ -486,12 +486,12 @@ suite('Workbench UI Services', () => {
service
.
showWhile
(
p
).
then
(()
=>
{
assert
.
strictEqual
(
true
,
testProgressBar
.
fDone
);
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_CLOSED
,
{
getId
:
()
=>
'
test.scopeId
'
});
p
=
TPromise
.
as
(
null
);
service
.
showWhile
(
p
).
then
(()
=>
{
assert
.
strictEqual
(
true
,
testProgressBar
.
fDone
);
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
editorId
:
'
test.scopeId
'
});
eventService
.
emit
(
EventType
.
EDITOR_OPENED
,
{
getId
:
()
=>
'
test.scopeId
'
});
assert
.
strictEqual
(
true
,
testProgressBar
.
fDone
);
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录