Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
03871624
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,发现更多精彩内容 >>
提交
03871624
编写于
6月 08, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Store editor view settings per group and not per file (fixes #7206)
上级
d9491c04
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
44 deletion
+68
-44
src/vs/workbench/browser/parts/editor/textEditor.ts
src/vs/workbench/browser/parts/editor/textEditor.ts
+0
-44
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
...s/workbench/parts/files/browser/editors/textFileEditor.ts
+68
-0
未找到文件。
src/vs/workbench/browser/parts/editor/textEditor.ts
浏览文件 @
03871624
...
...
@@ -9,9 +9,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
Dimension
,
Builder
}
from
'
vs/base/browser/builder
'
;
import
objects
=
require
(
'
vs/base/common/objects
'
);
import
{
CodeEditorWidget
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
import
{
IEditorViewState
}
from
'
vs/editor/common/editorCommon
'
;
import
{
OptionsChangeEvent
,
EventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
Scope
}
from
'
vs/workbench/common/memento
'
;
import
{
EditorInput
,
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorConfiguration
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
...
...
@@ -30,8 +28,6 @@ import {IModeService} from 'vs/editor/common/services/modeService';
import
{
IThemeService
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
const
EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
editorViewState
'
;
/**
* The base class of editors that leverage the text editor for the editing experience. This class is only intended to
* be subclassed and not instantiated.
...
...
@@ -181,46 +177,6 @@ export abstract class BaseTextEditor extends BaseEditor {
return
this
.
editorControl
.
getSelection
();
}
/**
* Saves the text editor view state under the given key.
*/
public
saveTextEditorViewState
(
storageService
:
IStorageService
,
key
:
string
):
void
{
let
editorViewState
=
this
.
editorControl
.
saveViewState
();
const
memento
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
let
editorViewStateMemento
=
memento
[
EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
!
editorViewStateMemento
)
{
editorViewStateMemento
=
{};
memento
[
EDITOR_VIEW_STATE_PREFERENCE_KEY
]
=
editorViewStateMemento
;
}
editorViewStateMemento
[
key
]
=
editorViewState
;
}
/**
* Clears the text editor view state under the given key.
*/
public
clearTextEditorViewState
(
storageService
:
IStorageService
,
keys
:
string
[]):
void
{
const
memento
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
let
editorViewStateMemento
=
memento
[
EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
editorViewStateMemento
)
{
keys
.
forEach
((
key
)
=>
delete
editorViewStateMemento
[
key
]);
}
}
/**
* Loads the text editor view state for the given key and returns it.
*/
public
loadTextEditorViewState
(
storageService
:
IStorageService
,
key
:
string
):
IEditorViewState
{
const
memento
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
let
editorViewStateMemento
=
memento
[
EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
editorViewStateMemento
)
{
return
editorViewStateMemento
[
key
];
}
return
null
;
}
public
dispose
():
void
{
// Destroy Editor Control
...
...
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
浏览文件 @
03871624
...
...
@@ -11,7 +11,9 @@ import {MIME_BINARY, MIME_TEXT} from 'vs/base/common/mime';
import
labels
=
require
(
'
vs/base/common/labels
'
);
import
types
=
require
(
'
vs/base/common/types
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
IEditorViewState
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
Scope
}
from
'
vs/workbench/common/memento
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
VIEWLET_ID
,
TEXT_FILE_EDITOR_ID
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
SaveErrorHandler
}
from
'
vs/workbench/parts/files/browser/saveErrorHandler
'
;
...
...
@@ -35,6 +37,15 @@ import {IModeService} from 'vs/editor/common/services/modeService';
import
{
IThemeService
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
const
LEGACY_EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
editorViewState
'
;
// TODO@Ben migration
const
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
textEditorViewState
'
;
interface
ITextEditorViewState
{
0
?:
IEditorViewState
;
1
?:
IEditorViewState
;
2
?:
IEditorViewState
;
}
/**
* An implementation of editor for file system resources.
*/
...
...
@@ -265,6 +276,63 @@ export class TextFileEditor extends BaseTextEditor {
return
true
;
// yes, we can!
}
/**
* Saves the text editor view state under the given key.
*/
private
saveTextEditorViewState
(
storageService
:
IStorageService
,
key
:
string
):
void
{
const
memento
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
let
textEditorViewStateMemento
=
memento
[
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
!
textEditorViewStateMemento
)
{
textEditorViewStateMemento
=
Object
.
create
(
null
);
memento
[
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
]
=
textEditorViewStateMemento
;
}
const
editorViewState
=
this
.
getControl
().
saveViewState
();
let
fileViewState
:
ITextEditorViewState
=
textEditorViewStateMemento
[
key
];
if
(
!
fileViewState
)
{
fileViewState
=
Object
.
create
(
null
);
textEditorViewStateMemento
[
key
]
=
fileViewState
;
}
if
(
typeof
this
.
position
===
'
number
'
)
{
fileViewState
[
this
.
position
]
=
editorViewState
;
}
}
/**
* Clears the text editor view state under the given key.
*/
private
clearTextEditorViewState
(
storageService
:
IStorageService
,
keys
:
string
[]):
void
{
const
memento
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
const
textEditorViewStateMemento
=
memento
[
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
textEditorViewStateMemento
)
{
keys
.
forEach
(
key
=>
delete
textEditorViewStateMemento
[
key
]);
}
}
/**
* Loads the text editor view state for the given key and returns it.
*/
private
loadTextEditorViewState
(
storageService
:
IStorageService
,
key
:
string
):
IEditorViewState
{
const
memento
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
const
textEditorViewStateMemento
=
memento
[
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
textEditorViewStateMemento
)
{
const
fileViewState
:
ITextEditorViewState
=
textEditorViewStateMemento
[
key
];
if
(
fileViewState
)
{
return
fileViewState
[
this
.
position
];
}
}
// TODO@Ben migration
const
legacyEditorViewStateMemento
=
memento
[
LEGACY_EDITOR_VIEW_STATE_PREFERENCE_KEY
];
if
(
legacyEditorViewStateMemento
)
{
return
legacyEditorViewStateMemento
[
key
];
}
return
null
;
}
public
clearInput
():
void
{
// Keep editor view state in settings to restore when coming back
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录