Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
c7a04cbd
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
c7a04cbd
编写于
6月 01, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get rid of editor event
上级
909be6a1
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
53 addition
and
150 deletion
+53
-150
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+5
-5
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
.../workbench/browser/parts/quickopen/quickOpenController.ts
+13
-17
src/vs/workbench/common/events.ts
src/vs/workbench/common/events.ts
+1
-43
src/vs/workbench/electron-browser/window.ts
src/vs/workbench/electron-browser/window.ts
+4
-9
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+11
-19
src/vs/workbench/parts/git/browser/views/changes/changesView.ts
.../workbench/parts/git/browser/views/changes/changesView.ts
+1
-1
src/vs/workbench/parts/markdown/browser/markdownExtension.ts
src/vs/workbench/parts/markdown/browser/markdownExtension.ts
+4
-4
src/vs/workbench/services/history/browser/history.ts
src/vs/workbench/services/history/browser/history.ts
+6
-12
src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts
.../workbench/test/browser/parts/quickOpen/quickopen.test.ts
+6
-22
src/vs/workbench/test/common/events.test.ts
src/vs/workbench/test/common/events.test.ts
+1
-17
src/vs/workbench/test/common/servicesTestUtils.ts
src/vs/workbench/test/common/servicesTestUtils.ts
+1
-1
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
c7a04cbd
...
...
@@ -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
,
Editor
Event
,
Editor
InputEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
,
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
'
;
...
...
@@ -390,7 +390,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
,
group
.
activeEditor
,
options
,
position
)
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
editor
);
}
return
editor
;
...
...
@@ -407,7 +407,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
,
input
,
options
,
position
)
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
editor
);
}
// Update Title Area
...
...
@@ -523,7 +523,7 @@ export class EditorPart extends Part implements IEditorPart {
this
.
doHideEditor
(
position
,
true
);
// Emit Input-Changed Event
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
null
,
null
,
null
,
position
)
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
{}
);
// Focus next group if we have an active one left
const
currentActiveGroup
=
this
.
stacks
.
activeGroup
;
...
...
@@ -805,7 +805,7 @@ 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_CHANGED
,
new
EditorEvent
(
activeEditor
)
);
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
{}
);
}
// Update Title Area
...
...
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
浏览文件 @
c7a04cbd
...
...
@@ -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
{
Editor
Event
,
Editor
InputEvent
,
EventType
}
from
'
vs/workbench/common/events
'
;
import
{
EditorInputEvent
,
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
'
;
...
...
@@ -124,7 +124,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
public
create
():
void
{
// Listen on Editor Input Changes to show in MRU List
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanged
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGED
,
(
)
=>
this
.
onEditorInputChanged
(
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_SET_INPUT_ERROR
,
(
e
:
EditorInputEvent
)
=>
this
.
onEditorInputSetError
(
e
)));
// Editor History Model
...
...
@@ -135,17 +135,14 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
}
}
private
onEditorInputChanged
(
e
:
EditorEvent
):
void
{
if
(
e
.
editorInput
)
{
// If an active editor is set, but is different from the one from the event, return early
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
&&
e
.
editor
&&
activeEditor
!==
e
.
editor
)
{
private
onEditorInputChanged
():
void
{
let
activeEditorInput
=
this
.
editorService
.
getActiveEditorInput
();
if
(
!
activeEditorInput
)
{
return
;
}
// Add to History
this
.
editorHistoryModel
.
add
(
e
.
e
ditorInput
);
this
.
editorHistoryModel
.
add
(
activeE
ditorInput
);
// Save to Local Storage periodically
if
(
this
.
autoSaveHistoryCounter
++
>=
AUTO_SAVE_HISTORY_THRESHOLD
)
{
...
...
@@ -153,7 +150,6 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
this
.
autoSaveHistoryCounter
=
0
;
}
}
}
private
onEditorInputSetError
(
e
:
EditorInputEvent
):
void
{
this
.
removeEditorHistoryEntry
(
e
.
editorInput
);
// make sure this input does not show up in history if it failed to open
...
...
src/vs/workbench/common/events.ts
浏览文件 @
c7a04cbd
...
...
@@ -6,8 +6,7 @@
import
URI
from
'
vs/base/common/uri
'
;
import
{
Event
}
from
'
vs/base/common/events
'
;
import
{
IEditor
,
IEditorInput
,
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
/**
* All workbench events are listed here.
...
...
@@ -111,47 +110,6 @@ export class EditorInputEvent 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/electron-browser/window.ts
浏览文件 @
c7a04cbd
...
...
@@ -9,7 +9,7 @@ import platform = require('vs/base/common/platform');
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
uri
from
'
vs/base/common/uri
'
;
import
{
Identifiers
}
from
'
vs/workbench/common/constants
'
;
import
{
EventType
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
}
from
'
vs/workbench/common/events
'
;
import
workbenchEditorCommon
=
require
(
'
vs/workbench/common/editor
'
);
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/common/viewletService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -52,13 +52,8 @@ export class ElectronWindow {
// React to editor input changes (Mac only)
if
(
platform
.
platform
===
platform
.
Platform
.
Mac
)
{
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorEvent
)
=>
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
!==
e
.
editor
)
{
return
;
// only care about active editor
}
let
fileInput
=
workbenchEditorCommon
.
asFileEditorInput
(
e
.
editorInput
,
true
);
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGED
,
()
=>
{
let
fileInput
=
workbenchEditorCommon
.
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
let
representedFilename
=
''
;
if
(
fileInput
)
{
representedFilename
=
fileInput
.
getResource
().
fsPath
;
...
...
@@ -127,7 +122,7 @@ export class ElectronWindow {
});
// Handle window.open() calls
(
<
any
>
window
).
open
=
function
(
url
:
string
,
target
:
string
,
features
:
string
,
replace
:
boolean
)
{
(
<
any
>
window
).
open
=
function
(
url
:
string
,
target
:
string
,
features
:
string
,
replace
:
boolean
)
{
shell
.
openExternal
(
url
);
return
null
;
...
...
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
c7a04cbd
...
...
@@ -15,7 +15,7 @@ import {Action, IActionRunner, IAction} from 'vs/base/common/actions';
import
{
prepareActions
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
E
ditorEvent
,
E
ventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
LocalFileChangeEvent
,
IFilesConfiguration
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFileStat
,
IResolveFileOptions
,
FileChangeType
,
FileChangesEvent
,
IFileChange
,
EventType
as
FileEventType
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -140,38 +140,30 @@ export class ExplorerView extends CollapsibleViewletView {
return
this
.
doRefresh
().
then
(()
=>
{
// When the explorer viewer is loaded, listen to changes to the editor input
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanged
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
)
=>
this
.
onEditorInputChanged
(
)));
// Also handle configuration updates
this
.
toDispose
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationUpdated
(
e
.
config
,
true
)));
});
}
private
onEditorInputChanged
(
e
:
EditorEvent
):
void
{
// During workbench startup, the editor area might restore more than one editor from a previous
// session. When this happens there might be editor input changing events for side editors that
// don't have focus. In these cases we do not adjust explorer selection for non-focused editors
// because we only want to react for the editor that has focus.
if
(
!
this
.
partService
.
isCreated
()
&&
e
.
editorOptions
&&
e
.
editorOptions
.
preserveFocus
)
{
return
;
}
private
onEditorInputChanged
():
void
{
let
activeInput
=
this
.
editorService
.
getActiveEditorInput
();
let
clearSelection
=
true
;
let
clearFocus
=
false
;
// Handle File Input
if
(
e
.
editorInput
&&
e
.
editor
Input
instanceof
FileEditorInput
)
{
let
fileInput
=
(
<
FileEditorInput
>
e
.
editorInput
);
if
(
active
Input
instanceof
FileEditorInput
)
{
const
fileResource
=
activeInput
.
getResource
(
);
// Always remember last opened file
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]
=
file
Input
.
getResource
()
.
toString
();
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]
=
file
Resource
.
toString
();
// Select file if input is FileEditorInput
if
(
this
.
isVisible
&&
this
.
contextService
.
isInsideWorkspace
(
file
Input
.
getResource
()
))
{
let
selection
=
this
.
hasSelection
(
file
Input
.
getResource
()
);
if
(
this
.
isVisible
&&
this
.
contextService
.
isInsideWorkspace
(
file
Resource
))
{
let
selection
=
this
.
hasSelection
(
file
Resource
);
if
(
!
selection
)
{
this
.
select
(
file
Input
.
getResource
()
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
select
(
file
Resource
).
done
(
null
,
errors
.
onUnexpectedError
);
}
clearSelection
=
false
;
...
...
@@ -179,7 +171,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
// Handle closed (convince explorer to not reopen any file when getting visible)
if
(
!
e
.
editor
Input
)
{
if
(
!
active
Input
)
{
this
.
settings
[
ExplorerView
.
MEMENTO_LAST_ACTIVE_FILE_RESOURCE
]
=
void
0
;
clearFocus
=
true
;
}
...
...
src/vs/workbench/parts/git/browser/views/changes/changesView.ts
浏览文件 @
c7a04cbd
...
...
@@ -103,7 +103,7 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
this
.
toDispose
=
[
this
.
smartCommitAction
=
this
.
instantiationService
.
createInstance
(
GitActions
.
SmartCommitAction
,
this
),
eventService
.
addListener2
(
WorkbenchEvents
.
EventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
WorkbenchEvents
.
EditorEvent
)
=>
this
.
onEditorInputChanged
(
e
.
editorInput
).
done
(
null
,
Errors
.
onUnexpectedError
)),
eventService
.
addListener2
(
WorkbenchEvents
.
EventType
.
EDITOR_INPUT_CHANGED
,
(
)
=>
this
.
onEditorInputChanged
(
this
.
editorService
.
getActiveEditorInput
()
).
done
(
null
,
Errors
.
onUnexpectedError
)),
this
.
gitService
.
addListener2
(
git
.
ServiceEvents
.
OPERATION_START
,
(
e
)
=>
this
.
onGitOperationStart
(
e
)),
this
.
gitService
.
addListener2
(
git
.
ServiceEvents
.
OPERATION_END
,
(
e
)
=>
this
.
onGitOperationEnd
(
e
)),
this
.
gitService
.
getModel
().
addListener2
(
git
.
ModelEvents
.
MODEL_UPDATED
,
this
.
onGitModelUpdate
.
bind
(
this
))
...
...
src/vs/workbench/parts/markdown/browser/markdownExtension.ts
浏览文件 @
c7a04cbd
...
...
@@ -13,7 +13,7 @@ import {getBaseThemeId} from 'vs/platform/theme/common/themes';
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IFrameEditor
}
from
'
vs/workbench/browser/parts/editor/iframeEditor
'
;
import
{
MarkdownEditorInput
}
from
'
vs/workbench/parts/markdown/common/markdownEditorInput
'
;
import
{
E
ditorEvent
,
E
ventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -67,7 +67,7 @@ export class MarkdownFileTracker implements IWorkbenchContribution {
this
.
configFileChangeListener
=
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigFileChange
(
e
));
// reload markdown editors when their resources change
this
.
editorInputChangeListener
=
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanged
(
e
));
this
.
editorInputChangeListener
=
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
)
=>
this
.
onEditorInputChanged
(
));
// initially read the config for CSS styles in preview
this
.
readMarkdownConfiguration
(
this
.
configurationService
.
getConfiguration
<
ILanguageConfiguration
>
());
...
...
@@ -79,8 +79,8 @@ export class MarkdownFileTracker implements IWorkbenchContribution {
});
}
private
onEditorInputChanged
(
e
:
EditorEvent
):
void
{
let
input
=
e
.
editorInput
;
private
onEditorInputChanged
():
void
{
let
input
=
this
.
editorService
.
getActiveEditorInput
()
;
if
(
input
instanceof
MarkdownEditorInput
)
{
let
markdownResource
=
input
.
getResource
();
let
editorModel
=
this
.
modelService
.
getModel
(
markdownResource
);
...
...
src/vs/workbench/services/history/browser/history.ts
浏览文件 @
c7a04cbd
...
...
@@ -11,7 +11,7 @@ import {EventType} from 'vs/base/common/events';
import
{
IEditor
as
IBaseEditor
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TextEditorOptions
,
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
E
ditorEvent
,
E
ventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
...
...
@@ -81,13 +81,10 @@ export abstract class BaseHistoryService {
window
.
document
.
title
=
this
.
getWindowTitle
(
null
);
// Editor Input Changes
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChanged
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
(
)
=>
this
.
onEditorInputChanged
(
)));
}
private
onEditorInputChanged
(
event
:
EditorEvent
):
void
{
// Propagate to history
this
.
onEditorEvent
(
event
.
editor
);
private
onEditorInputChanged
():
void
{
// Dispose old listeners
dispose
(
this
.
activeEditorListeners
);
...
...
@@ -96,6 +93,9 @@ export abstract class BaseHistoryService {
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeInput
=
activeEditor
?
activeEditor
.
input
:
void
0
;
// Propagate to history
this
.
onEditorEvent
(
activeEditor
);
// Apply listener for dirty changes
if
(
activeInput
instanceof
EditorInput
)
{
this
.
activeEditorListeners
.
push
(
activeInput
.
onDidChangeDirty
(()
=>
{
...
...
@@ -115,12 +115,6 @@ export abstract class BaseHistoryService {
private
onEditorEvent
(
editor
:
IBaseEditor
):
void
{
let
input
=
editor
?
editor
.
input
:
null
;
// If an active editor is set, but is different from the one from the event, prevent update because the editor is not active.
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
&&
editor
&&
activeEditor
!==
editor
)
{
return
;
}
// Calculate New Window Title
this
.
updateWindowTitle
(
input
);
...
...
src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts
浏览文件 @
c7a04cbd
...
...
@@ -25,8 +25,7 @@ import URI from 'vs/base/common/uri';
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
EventType
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EventType
}
from
'
vs/workbench/common/events
'
;
function
toResource
(
path
)
{
return
URI
.
file
(
join
(
'
C:
\\
'
,
path
));
...
...
@@ -77,24 +76,6 @@ suite('Workbench QuickOpen', () => {
assert
(
!
entry2
.
run
(
Mode
.
PREVIEW
,
{
event
:
null
,
quickNavigateConfiguration
:
null
,
keymods
:
[]
}));
});
test
(
'
EditorHistoryEntry is removed when open fails
'
,
()
=>
{
let
editorService
=
new
TestEditorService
();
let
contextService
=
new
TestContextService
();
let
inst
=
new
InstantiationService
();
let
model
=
new
EditorHistoryModel
(
editorService
,
null
,
contextService
);
let
input1
=
inst
.
createInstance
(
StringEditorInput
,
'
name1
'
,
'
description
'
,
'
value1
'
,
'
text/plain
'
,
false
);
model
.
add
(
input1
);
assert
.
equal
(
1
,
model
.
getEntries
().
length
);
assert
(
model
.
getEntries
()[
0
].
run
(
Mode
.
OPEN
,
{
event
:
null
,
quickNavigateConfiguration
:
null
,
keymods
:
[]
}));
assert
.
equal
(
0
,
model
.
getEntries
().
length
);
});
test
(
'
EditorHistoryModel
'
,
()
=>
{
Registry
.
as
(
'
workbench.contributions.editors
'
).
setInstantiationService
(
new
InstantiationService
());
...
...
@@ -240,13 +221,16 @@ 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
);
eventService
.
emit
(
EventType
.
EDITOR_INPUT_CHANGED
,
event
);
editorService
.
activeEditorInput
=
cinput1
;
eventService
.
emit
(
EventType
.
EDITOR_INPUT_CHANGED
,
{});
assert
.
equal
(
1
,
controller
.
getEditorHistoryModel
().
getEntries
().
length
);
cinput1
.
dispose
();
assert
.
equal
(
1
,
controller
.
getEditorHistoryModel
().
getEntries
().
length
);
editorService
.
activeEditorInput
=
void
0
;
});
});
\ No newline at end of file
src/vs/workbench/test/common/events.test.ts
浏览文件 @
c7a04cbd
...
...
@@ -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
{
CompositeEvent
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
CompositeEvent
}
from
'
vs/workbench/common/events
'
;
let
FileChangesEvent
=
Files
.
FileChangesEvent
;
...
...
@@ -24,22 +24,6 @@ suite('Workbench Events', () => {
assert
(
event
.
time
);
});
test
(
'
Editor Change Event
'
,
function
()
{
let
editor
:
any
=
{
getId
:
()
=>
'
foo.bar
'
};
let
origEvent
:
any
=
{};
let
input
:
any
=
{};
let
options
:
any
=
{};
let
id
=
'
foo.bar
'
;
let
event
=
new
EditorEvent
(
editor
,
input
,
options
,
0
,
origEvent
);
assert
.
strictEqual
(
event
.
editor
,
editor
);
assert
.
strictEqual
(
event
.
originalEvent
,
origEvent
);
assert
.
strictEqual
(
event
.
editorId
,
id
);
assert
.
strictEqual
(
event
.
editorInput
,
input
);
assert
.
strictEqual
(
event
.
editorOptions
,
options
);
assert
(
event
.
time
);
});
test
(
'
Property Change Event
'
,
function
()
{
let
key
=
'
foo
'
;
let
origEvent
:
any
=
{};
...
...
src/vs/workbench/test/common/servicesTestUtils.ts
浏览文件 @
c7a04cbd
...
...
@@ -336,7 +336,7 @@ export class TestEditorService implements WorkbenchEditorService.IWorkbenchEdito
public
getActiveEditorInput
():
IEditorInput
{
this
.
callback
(
'
getActiveEditorInput
'
);
return
null
;
return
this
.
activeEditorInput
;
}
public
getVisibleEditors
():
IEditor
[]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录