Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0ee66e5d
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,发现更多精彩内容 >>
提交
0ee66e5d
编写于
6月 06, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - clean up view state for resources/untitled when input gets disposed
上级
961c14ae
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
28 deletion
+27
-28
src/vs/workbench/browser/parts/editor/textResourceEditor.ts
src/vs/workbench/browser/parts/editor/textResourceEditor.ts
+25
-22
src/vs/workbench/parts/output/browser/outputPanel.ts
src/vs/workbench/parts/output/browser/outputPanel.ts
+1
-3
src/vs/workbench/test/common/editor/editorDiffModel.test.ts
src/vs/workbench/test/common/editor/editorDiffModel.test.ts
+1
-3
未找到文件。
src/vs/workbench/browser/parts/editor/textResourceEditor.ts
浏览文件 @
0ee66e5d
...
@@ -14,16 +14,15 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
...
@@ -14,16 +14,15 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
import
{
BaseTextEditorModel
}
from
'
vs/workbench/common/editor/textEditorModel
'
;
import
{
BaseTextEditorModel
}
from
'
vs/workbench/common/editor/textEditorModel
'
;
import
{
UntitledEditorInput
}
from
'
vs/workbench/common/editor/untitledEditorInput
'
;
import
{
UntitledEditorInput
}
from
'
vs/workbench/common/editor/untitledEditorInput
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
once
}
from
"
vs/base/common/event
"
;
/**
/**
* An editor implementation that is capable of showing the contents of resource inputs. Uses
* An editor implementation that is capable of showing the contents of resource inputs. Uses
...
@@ -39,20 +38,11 @@ export class TextResourceEditor extends BaseTextEditor {
...
@@ -39,20 +38,11 @@ export class TextResourceEditor extends BaseTextEditor {
@
IStorageService
storageService
:
IStorageService
,
@
IStorageService
storageService
:
IStorageService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IThemeService
themeService
:
IThemeService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IModeService
modeService
:
IModeService
,
@
IModeService
modeService
:
IModeService
,
@
ITextFileService
textFileService
:
ITextFileService
@
ITextFileService
textFileService
:
ITextFileService
)
{
)
{
super
(
TextResourceEditor
.
ID
,
telemetryService
,
instantiationService
,
storageService
,
configurationService
,
themeService
,
modeService
,
textFileService
,
editorGroupService
);
super
(
TextResourceEditor
.
ID
,
telemetryService
,
instantiationService
,
storageService
,
configurationService
,
themeService
,
modeService
,
textFileService
,
editorGroupService
);
this
.
toUnbind
.
push
(
this
.
untitledEditorService
.
onDidChangeDirty
(
e
=>
this
.
onUntitledDirtyChange
(
e
)));
}
private
onUntitledDirtyChange
(
resource
:
URI
):
void
{
if
(
!
this
.
untitledEditorService
.
isDirty
(
resource
))
{
this
.
clearTextEditorViewState
([
resource
.
toString
()]);
// untitled file got reverted, so remove view state
}
}
}
public
getTitle
():
string
{
public
getTitle
():
string
{
...
@@ -83,7 +73,7 @@ export class TextResourceEditor extends BaseTextEditor {
...
@@ -83,7 +73,7 @@ export class TextResourceEditor extends BaseTextEditor {
}
}
// Remember view settings if input changes
// Remember view settings if input changes
this
.
saveTextEditorViewState
(
oldInput
);
this
.
saveTextEditorViewState
ForInput
(
oldInput
);
// Different Input (Reload)
// Different Input (Reload)
return
input
.
resolve
(
true
).
then
((
resolvedModel
:
EditorModel
)
=>
{
return
input
.
resolve
(
true
).
then
((
resolvedModel
:
EditorModel
)
=>
{
...
@@ -166,7 +156,7 @@ export class TextResourceEditor extends BaseTextEditor {
...
@@ -166,7 +156,7 @@ export class TextResourceEditor extends BaseTextEditor {
public
clearInput
():
void
{
public
clearInput
():
void
{
// Keep editor view state in settings to restore when coming back
// Keep editor view state in settings to restore when coming back
this
.
saveTextEditorViewState
(
this
.
input
);
this
.
saveTextEditorViewState
ForInput
(
this
.
input
);
// Clear Model
// Clear Model
this
.
getControl
().
setModel
(
null
);
this
.
getControl
().
setModel
(
null
);
...
@@ -176,22 +166,35 @@ export class TextResourceEditor extends BaseTextEditor {
...
@@ -176,22 +166,35 @@ export class TextResourceEditor extends BaseTextEditor {
public
shutdown
():
void
{
public
shutdown
():
void
{
// Save View State
// Save View State (only for untitled)
this
.
saveTextEditorViewState
(
this
.
input
);
if
(
this
.
input
instanceof
UntitledEditorInput
)
{
this
.
saveTextEditorViewStateForInput
(
this
.
input
);
}
// Call Super
// Call Super
super
.
shutdown
();
super
.
shutdown
();
}
}
protected
saveTextEditorViewState
(
input
:
EditorInput
):
void
;
protected
saveTextEditorViewStateForInput
(
input
:
EditorInput
):
void
{
protected
saveTextEditorViewState
(
key
:
string
):
void
;
if
(
!
(
input
instanceof
UntitledEditorInput
)
&&
!
(
input
instanceof
ResourceEditorInput
))
{
protected
saveTextEditorViewState
(
arg1
:
EditorInput
|
string
):
void
{
return
;
// only enabled for untitled and resource inputs
if
(
typeof
arg1
===
'
string
'
)
{
return
super
.
saveTextEditorViewState
(
arg1
);
}
}
if
((
arg1
instanceof
UntitledEditorInput
||
arg1
instanceof
ResourceEditorInput
)
&&
!
arg1
.
isDisposed
())
{
const
key
=
input
.
getResource
().
toString
();
return
super
.
saveTextEditorViewState
(
arg1
.
getResource
().
toString
());
// Clear view state if input is disposed
if
(
input
.
isDisposed
())
{
super
.
clearTextEditorViewState
([
key
]);
}
// Otherwise save it
else
{
super
.
saveTextEditorViewState
(
key
);
// Make sure to clean up when the input gets disposed
once
(
input
.
onDispose
)(()
=>
{
super
.
clearTextEditorViewState
([
key
]);
});
}
}
}
}
}
}
\ No newline at end of file
src/vs/workbench/parts/output/browser/outputPanel.ts
浏览文件 @
0ee66e5d
...
@@ -22,7 +22,6 @@ import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResour
...
@@ -22,7 +22,6 @@ import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResour
import
{
OutputEditors
,
OUTPUT_PANEL_ID
,
IOutputService
,
CONTEXT_IN_OUTPUT
}
from
'
vs/workbench/parts/output/common/output
'
;
import
{
OutputEditors
,
OUTPUT_PANEL_ID
,
IOutputService
,
CONTEXT_IN_OUTPUT
}
from
'
vs/workbench/parts/output/common/output
'
;
import
{
SwitchOutputAction
,
SwitchOutputActionItem
,
ClearOutputAction
,
ToggleOutputScrollLockAction
}
from
'
vs/workbench/parts/output/browser/outputActions
'
;
import
{
SwitchOutputAction
,
SwitchOutputActionItem
,
ClearOutputAction
,
ToggleOutputScrollLockAction
}
from
'
vs/workbench/parts/output/browser/outputActions
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
...
@@ -39,13 +38,12 @@ export class OutputPanel extends TextResourceEditor {
...
@@ -39,13 +38,12 @@ export class OutputPanel extends TextResourceEditor {
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IThemeService
themeService
:
IThemeService
,
@
IOutputService
private
outputService
:
IOutputService
,
@
IOutputService
private
outputService
:
IOutputService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IModeService
modeService
:
IModeService
,
@
IModeService
modeService
:
IModeService
,
@
ITextFileService
textFileService
:
ITextFileService
@
ITextFileService
textFileService
:
ITextFileService
)
{
)
{
super
(
telemetryService
,
instantiationService
,
storageService
,
configurationService
,
themeService
,
untitledEditorService
,
editorGroupService
,
modeService
,
textFileService
);
super
(
telemetryService
,
instantiationService
,
storageService
,
configurationService
,
themeService
,
editorGroupService
,
modeService
,
textFileService
);
this
.
scopedInstantiationService
=
instantiationService
;
this
.
scopedInstantiationService
=
instantiationService
;
this
.
toDispose
=
[];
this
.
toDispose
=
[];
...
...
src/vs/workbench/test/common/editor/editorDiffModel.test.ts
浏览文件 @
0ee66e5d
...
@@ -16,7 +16,6 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
...
@@ -16,7 +16,6 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
TestTextFileService
,
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
TestTextFileService
,
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
TPromise
}
from
"
vs/base/common/winjs.base
"
;
import
{
TPromise
}
from
"
vs/base/common/winjs.base
"
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModel
}
from
'
vs/editor/common/editorCommon
'
;
...
@@ -30,8 +29,7 @@ class ServiceAccessor {
...
@@ -30,8 +29,7 @@ class ServiceAccessor {
@
ITextModelResolverService
public
textModelResolverService
:
ITextModelResolverService
,
@
ITextModelResolverService
public
textModelResolverService
:
ITextModelResolverService
,
@
IModelService
public
modelService
:
IModelService
,
@
IModelService
public
modelService
:
IModelService
,
@
IModeService
public
modeService
:
IModeService
,
@
IModeService
public
modeService
:
IModeService
,
@
ITextFileService
public
textFileService
:
TestTextFileService
,
@
ITextFileService
public
textFileService
:
TestTextFileService
@
IUntitledEditorService
public
untitledEditorService
:
IUntitledEditorService
)
{
)
{
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录