Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ec4d50c2
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,发现更多精彩内容 >>
提交
ec4d50c2
编写于
6月 01, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
starting events cleanup
上级
ecf180ea
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
52 deletion
+18
-52
src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts
...s/workbench/browser/parts/quickopen/editorHistoryModel.ts
+6
-4
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
.../workbench/browser/parts/quickopen/quickOpenController.ts
+3
-3
src/vs/workbench/common/events.ts
src/vs/workbench/common/events.ts
+5
-31
src/vs/workbench/parts/files/browser/fileTracker.ts
src/vs/workbench/parts/files/browser/fileTracker.ts
+3
-3
src/vs/workbench/test/common/events.test.ts
src/vs/workbench/test/common/events.test.ts
+1
-11
未找到文件。
src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts
浏览文件 @
ec4d50c2
...
...
@@ -14,6 +14,7 @@ import URI from 'vs/base/common/uri';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
labels
=
require
(
'
vs/base/common/labels
'
);
import
{
EventType
}
from
'
vs/base/common/events
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Mode
,
IEntryRunContext
}
from
'
vs/base/parts/quickopen/common/quickOpen
'
;
import
{
QuickOpenEntry
,
QuickOpenModel
,
IHighlight
}
from
'
vs/base/parts/quickopen/browser/quickOpenModel
'
;
import
{
EditorInput
,
getUntitledOrFileResource
}
from
'
vs/workbench/common/editor
'
;
...
...
@@ -132,14 +133,14 @@ export class EditorHistoryModel extends QuickOpenModel {
this
.
registry
=
Registry
.
as
<
IEditorRegistry
>
(
Extensions
.
Editors
);
}
public
add
(
input
:
EditorInput
,
index
?:
number
):
void
{
public
add
(
input
:
I
EditorInput
,
index
?:
number
):
void
{
// Ensure we have at least a name to show
if
(
!
input
.
getName
())
{
return
;
}
const
entry
=
new
EditorHistoryEntry
(
this
.
editorService
,
this
.
contextService
,
input
,
null
,
null
,
this
);
const
entry
=
new
EditorHistoryEntry
(
this
.
editorService
,
this
.
contextService
,
<
EditorInput
>
input
,
null
,
null
,
this
);
// Remove any existing entry and add to the beginning if we do not get an index
if
(
typeof
index
!==
'
number
'
)
{
...
...
@@ -187,8 +188,9 @@ export class EditorHistoryModel extends QuickOpenModel {
// Factory failed, just remove entry then
this
.
remove
(
input
);
}
public
remove
(
input
:
EditorInput
):
void
{
let
index
=
this
.
indexOf
(
input
);
public
remove
(
input
:
IEditorInput
):
void
{
let
index
=
this
.
indexOf
(
<
EditorInput
>
input
);
if
(
index
>=
0
)
{
const
entry
=
<
EditorHistoryEntry
>
this
.
entries
[
index
];
if
(
entry
)
{
...
...
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
浏览文件 @
ec4d50c2
...
...
@@ -23,10 +23,10 @@ import {WorkbenchComponent} from 'vs/workbench/common/component';
import
{
EditorEvent
,
EventType
}
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
'
;
import
{
Scope
}
from
'
vs/workbench/common/memento
'
;
import
{
QuickOpenHandler
,
QuickOpenHandlerDescriptor
,
IQuickOpenRegistry
,
Extensions
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
EditorHistoryModel
}
from
'
vs/workbench/browser/parts/quickopen/editorHistoryModel
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IPickOpenEntry
,
IInputOptions
,
IQuickOpenService
,
IPickOptions
,
IShowOptions
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
...
...
@@ -161,7 +161,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
}
}
public
getEditorHistory
():
EditorInput
[]
{
public
getEditorHistory
():
I
EditorInput
[]
{
return
this
.
editorHistoryModel
?
this
.
editorHistoryModel
.
getEntries
().
map
((
entry
)
=>
entry
.
getInput
())
:
[];
}
...
...
@@ -169,7 +169,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
this
.
editorHistoryModel
.
setEntries
([]);
}
public
removeEditorHistoryEntry
(
input
:
EditorInput
):
void
{
public
removeEditorHistoryEntry
(
input
:
I
EditorInput
):
void
{
this
.
editorHistoryModel
.
remove
(
input
);
}
...
...
src/vs/workbench/common/events.ts
浏览文件 @
ec4d50c2
...
...
@@ -6,8 +6,8 @@
import
URI
from
'
vs/base/common/uri
'
;
import
{
Event
}
from
'
vs/base/common/events
'
;
import
{
IEditor
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Editor
Input
,
Editor
Options
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditor
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
...
...
@@ -130,13 +130,13 @@ export class EventType {
export
class
EditorEvent
extends
Event
{
public
editor
:
IEditor
;
public
editorId
:
string
;
public
editorInput
:
EditorInput
;
public
editorInput
:
I
EditorInput
;
public
editorOptions
:
EditorOptions
;
public
position
:
Position
;
private
prevented
:
boolean
;
constructor
(
editor
:
IEditor
,
editorId
:
string
,
editorInput
:
EditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
constructor
(
editor
:
IEditor
,
editorId
:
string
,
editorInput
:
I
EditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
super
(
originalEvent
);
this
.
editor
=
editor
;
...
...
@@ -155,26 +155,13 @@ export class EditorEvent extends Event {
}
}
/**
* Editor input events are being emitted when the editor input state changes.
*/
export
class
EditorInputEvent
extends
Event
{
public
editorInput
:
EditorInput
;
constructor
(
editorInput
:
EditorInput
,
originalEvent
?:
any
)
{
super
(
originalEvent
);
this
.
editorInput
=
editorInput
;
}
}
/**
* A subclass of EditorEvent for text editor selection changes.
*/
export
class
TextEditorSelectionEvent
extends
EditorEvent
{
public
selection
:
Selection
;
constructor
(
selection
:
Selection
,
editor
:
IEditor
,
editorId
:
string
,
editorInput
:
EditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
constructor
(
selection
:
Selection
,
editor
:
IEditor
,
editorId
:
string
,
editorInput
:
I
EditorInput
,
editorOptions
:
EditorOptions
,
position
:
Position
,
originalEvent
?:
any
)
{
super
(
editor
,
editorId
,
editorInput
,
editorOptions
,
position
,
originalEvent
);
this
.
selection
=
selection
;
...
...
@@ -198,19 +185,6 @@ export class OptionsChangeEvent extends Event {
}
}
/**
* Command events are emitted when an action is being executed through a command handler (Keybinding).
*/
export
class
CommandEvent
extends
Event
{
public
actionId
:
string
;
constructor
(
actionId
:
string
,
originalEvent
?:
any
)
{
super
(
originalEvent
);
this
.
actionId
=
actionId
;
}
}
/**
* Composite events are emitted when a composite opens or closes in the sidebar or panel.
*/
...
...
src/vs/workbench/parts/files/browser/fileTracker.ts
浏览文件 @
ec4d50c2
...
...
@@ -20,7 +20,7 @@ import {FileEditorInput} from 'vs/workbench/parts/files/browser/editors/fileEdit
import
{
IFrameEditorInput
}
from
'
vs/workbench/common/editor/iframeEditorInput
'
;
import
{
TextFileEditorModel
,
CACHE
}
from
'
vs/workbench/parts/files/common/editors/textFileEditorModel
'
;
import
{
IFrameEditor
}
from
'
vs/workbench/browser/parts/editor/iframeEditor
'
;
import
{
EventType
as
WorkbenchEventType
,
EditorInputEvent
,
UntitledEditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
,
UntitledEditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
...
...
@@ -63,7 +63,7 @@ export class FileTracker implements IWorkbenchContribution {
private
registerListeners
():
void
{
// Update editors and inputs from local changes and saves
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorInputEvent
)
=>
this
.
onEditorInputChanged
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
)
=>
this
.
onEditorInputChanged
(
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DELETED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledEditorDeleted
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DIRTY
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledEditorDirty
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_DIRTY
,
(
e
:
TextFileChangeEvent
)
=>
this
.
onTextFileDirty
(
e
)));
...
...
@@ -76,7 +76,7 @@ export class FileTracker implements IWorkbenchContribution {
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
CommonFileEventType
.
FILE_CHANGES
,
(
e
:
FileChangesEvent
)
=>
this
.
onFileChanges
(
e
)));
}
private
onEditorInputChanged
(
e
:
EditorInputEvent
):
void
{
private
onEditorInputChanged
():
void
{
this
.
disposeUnusedTextFileModels
();
}
...
...
src/vs/workbench/test/common/events.test.ts
浏览文件 @
ec4d50c2
...
...
@@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri';
import
*
as
Paths
from
'
vs/base/common/paths
'
;
import
*
as
Files
from
'
vs/platform/files/common/files
'
;
import
{
Event
,
PropertyChangeEvent
}
from
'
vs/base/common/events
'
;
import
{
Com
mandEvent
,
Com
positeEvent
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
CompositeEvent
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
let
FileChangesEvent
=
Files
.
FileChangesEvent
;
...
...
@@ -24,16 +24,6 @@ suite('Workbench Events', () => {
assert
(
event
.
time
);
});
test
(
'
Command Event
'
,
function
()
{
let
actionId
=
'
foo.bar
'
;
let
origEvent
=
{};
let
event
=
new
CommandEvent
(
actionId
,
origEvent
);
assert
.
strictEqual
(
event
.
originalEvent
,
origEvent
);
assert
.
strictEqual
(
event
.
actionId
,
actionId
);
assert
(
event
.
time
);
});
test
(
'
Editor Change Event
'
,
function
()
{
let
editor
:
any
=
{};
let
origEvent
:
any
=
{};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录