Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
82d9feb3
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,发现更多精彩内容 >>
提交
82d9feb3
编写于
10月 31, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better fix for #8202
上级
be2143dd
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
34 addition
and
50 deletion
+34
-50
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+11
-15
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+1
-4
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+3
-5
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+4
-9
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
...s/workbench/parts/files/browser/editors/textFileEditor.ts
+15
-17
未找到文件。
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
82d9feb3
...
...
@@ -251,23 +251,19 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
if
(
!
this
.
cursor
||
!
this
.
hasView
)
{
return
;
}
if
(
state
)
{
var
codeEditorState
=
<
editorCommon
.
ICodeEditorViewState
>
state
;
var
c
ursorState
=
codeEditorState
.
cursorState
;
if
(
cursorState
)
{
var
s
=
<
any
>
state
;
if
(
s
&&
s
.
cursorState
&&
s
.
viewState
)
{
var
c
odeEditorState
=
<
editorCommon
.
ICodeEditorViewState
>
s
;
var
cursorState
=
<
any
>
codeEditorState
.
cursorState
;
if
(
Array
.
isArray
(
cursorState
))
{
this
.
cursor
.
restoreState
(
<
editorCommon
.
ICursorState
[]
>
cursorState
);
}
else
{
// Backwards compatibility
this
.
cursor
.
restoreState
([
<
editorCommon
.
ICursorState
>
cursorState
]);
}
}
if
(
codeEditorState
.
viewState
)
{
this
.
_view
.
restoreState
(
codeEditorState
.
viewState
);
}
let
contributionsState
=
codeEditorState
.
contributionsState
||
{};
let
contributionsState
=
s
.
contributionsState
||
{};
let
keys
=
Object
.
keys
(
this
.
_contributions
);
for
(
let
i
=
0
,
len
=
keys
.
length
;
i
<
len
;
i
++
)
{
let
id
=
keys
[
i
];
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
82d9feb3
...
...
@@ -2965,10 +2965,7 @@ export interface IViewState {
export
interface
ICodeEditorViewState
extends
IEditorViewState
{
cursorState
:
ICursorState
[];
viewState
:
IViewState
;
contributionsState
:
IContributionsViewState
;
}
export
interface
IContributionsViewState
{
[
id
:
string
]:
any
;
contributionsState
:
{
[
id
:
string
]:
any
};
}
/**
...
...
src/vs/monaco.d.ts
浏览文件 @
82d9feb3
...
...
@@ -2665,11 +2665,9 @@ declare module monaco.editor {
export
interface
ICodeEditorViewState
extends
IEditorViewState
{
cursorState
:
ICursorState
[];
viewState
:
IViewState
;
contributionsState
:
IContributionsViewState
;
}
export
interface
IContributionsViewState
{
contributionsState
:
{
[
id
:
string
]:
any
;
};
}
/**
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
82d9feb3
...
...
@@ -8,7 +8,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
{
IEditor
,
ICommonCodeEditor
,
IEditorViewState
,
IEditorOptions
as
ICodeEditorOptions
,
ICodeEditorViewState
,
IContributionsViewState
,
EditorType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditor
,
ICommonCodeEditor
,
IEditorViewState
,
IEditorOptions
as
ICodeEditorOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IResourceInput
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
...
...
@@ -614,7 +614,7 @@ export class TextEditorOptions extends EditorOptions {
*
* @return if something was applied
*/
public
apply
(
editor
:
IEditor
,
extraContributionsViewState
?:
IContributionsViewState
):
boolean
{
public
apply
(
editor
:
IEditor
):
boolean
{
// Editor options
if
(
this
.
editorOptions
)
{
...
...
@@ -622,10 +622,10 @@ export class TextEditorOptions extends EditorOptions {
}
// View state
return
this
.
applyViewState
(
editor
,
extraContributionsViewState
);
return
this
.
applyViewState
(
editor
);
}
private
applyViewState
(
editor
:
IEditor
,
extraContributionsViewState
?:
IContributionsViewState
):
boolean
{
private
applyViewState
(
editor
:
IEditor
):
boolean
{
let
gotApplied
=
false
;
// First try viewstate
...
...
@@ -637,11 +637,6 @@ export class TextEditorOptions extends EditorOptions {
// Otherwise check for selection
else
if
(
!
types
.
isUndefinedOrNull
(
this
.
startLineNumber
)
&&
!
types
.
isUndefinedOrNull
(
this
.
startColumn
))
{
// Additional Contributions View State only applies if we did not have view state otherwise
if
(
extraContributionsViewState
&&
editor
.
getEditorType
()
===
EditorType
.
ICodeEditor
)
{
editor
.
restoreViewState
({
contributionsState
:
extraContributionsViewState
}
as
ICodeEditorViewState
);
}
// Select
if
(
!
types
.
isUndefinedOrNull
(
this
.
endLineNumber
)
&&
!
types
.
isUndefinedOrNull
(
this
.
endColumn
))
{
const
range
=
{
...
...
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
浏览文件 @
82d9feb3
...
...
@@ -10,7 +10,7 @@ import errors = require('vs/base/common/errors');
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
I
Code
EditorViewState
}
from
'
vs/editor/common/editorCommon
'
;
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
'
;
...
...
@@ -37,9 +37,9 @@ import { IThemeService } from 'vs/workbench/services/themes/common/themeService'
const
TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY
=
'
textEditorViewState
'
;
interface
ITextEditorViewState
{
0
?:
I
Code
EditorViewState
;
1
?:
I
Code
EditorViewState
;
2
?:
I
Code
EditorViewState
;
0
?:
IEditorViewState
;
1
?:
IEditorViewState
;
2
?:
IEditorViewState
;
}
/**
...
...
@@ -84,7 +84,7 @@ export class TextFileEditor extends BaseTextEditor {
return
<
FileEditorInput
>
super
.
getInput
();
}
public
setInput
(
input
:
FileEditorInput
,
options
:
Text
EditorOptions
):
TPromise
<
void
>
{
public
setInput
(
input
:
FileEditorInput
,
options
:
EditorOptions
):
TPromise
<
void
>
{
const
oldInput
=
this
.
getInput
();
super
.
setInput
(
input
,
options
);
...
...
@@ -105,8 +105,8 @@ export class TextFileEditor extends BaseTextEditor {
if
(
!
forceOpen
&&
input
.
matches
(
oldInput
))
{
// TextOptions (avoiding instanceof here for a reason, do not change!)
if
(
options
&&
types
.
isFunction
(
options
.
apply
))
{
options
.
apply
(
this
.
getControl
());
if
(
options
&&
types
.
isFunction
(
(
<
TextEditorOptions
>
options
)
.
apply
))
{
(
<
TextEditorOptions
>
options
)
.
apply
(
this
.
getControl
());
}
return
TPromise
.
as
<
void
>
(
null
);
...
...
@@ -145,17 +145,15 @@ export class TextFileEditor extends BaseTextEditor {
const
textEditor
=
this
.
getControl
();
textEditor
.
setModel
(
textFileModel
.
textEditorModel
);
const
previousEditorViewState
=
this
.
loadTextEditorViewState
(
this
.
storageService
,
this
.
getInput
().
getResource
().
toString
());
// TextOptions (avoiding instanceof here for a reason, do not change!)
let
optionsGotApplied
=
false
;
if
(
options
&&
types
.
isFunction
(
options
.
apply
))
{
optionsGotApplied
=
options
.
apply
(
textEditor
,
previousEditorViewState
&&
previousEditorViewState
.
contributionsState
);
// Always restore View State if any associated
const
editorViewState
=
this
.
loadTextEditorViewState
(
this
.
storageService
,
this
.
getInput
().
getResource
().
toString
());
if
(
editorViewState
)
{
textEditor
.
restoreViewState
(
editorViewState
);
}
//
Otherwise restore previous View State if available
if
(
!
optionsGotApplied
&&
previousEditorViewState
)
{
textEditor
.
restoreViewState
(
previousEditorViewState
);
//
TextOptions (avoiding instanceof here for a reason, do not change!)
if
(
options
&&
types
.
isFunction
((
<
TextEditorOptions
>
options
).
apply
)
)
{
(
<
TextEditorOptions
>
options
).
apply
(
textEditor
);
}
},
(
error
)
=>
{
...
...
@@ -266,7 +264,7 @@ export class TextFileEditor extends BaseTextEditor {
/**
* Loads the text editor view state for the given key and returns it.
*/
private
loadTextEditorViewState
(
storageService
:
IStorageService
,
key
:
string
):
I
Code
EditorViewState
{
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
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录