Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e466584a
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,发现更多精彩内容 >>
提交
e466584a
编写于
7月 28, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
store pending config change event and 'replay' when becoming visible, fixes #9892
上级
89fbf8c8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
54 deletion
+50
-54
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+19
-30
src/vs/editor/common/services/modeService.ts
src/vs/editor/common/services/modeService.ts
+0
-1
src/vs/editor/common/services/modeServiceImpl.ts
src/vs/editor/common/services/modeServiceImpl.ts
+4
-1
src/vs/editor/test/common/mocks/mockModeService.ts
src/vs/editor/test/common/mocks/mockModeService.ts
+0
-3
src/vs/workbench/browser/parts/editor/textEditor.ts
src/vs/workbench/browser/parts/editor/textEditor.ts
+27
-19
未找到文件。
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
e466584a
...
...
@@ -541,44 +541,33 @@ export class EditorConfiguration {
/**
* Ask the provided configuration service to apply its configuration to the provided editor.
*/
public
static
apply
(
config
:
any
,
editor
?:
editorCommon
.
IEditor
):
void
;
public
static
apply
(
config
:
any
,
editor
?:
editorCommon
.
IEditor
[]):
void
;
public
static
apply
(
config
:
any
,
editorOrArray
?:
any
):
void
{
public
static
apply
(
config
:
any
,
editor
:
editorCommon
.
IEditor
):
void
{
if
(
!
config
)
{
return
;
}
let
editors
:
editorCommon
.
IEditor
[]
=
editorOrArray
;
if
(
!
Array
.
isArray
(
editorOrArray
))
{
editors
=
[
editorOrArray
];
}
for
(
let
i
=
0
;
i
<
editors
.
length
;
i
++
)
{
let
editor
=
editors
[
i
];
// Editor Settings (Code Editor, Diff, Terminal)
if
(
editor
&&
typeof
editor
.
updateOptions
===
'
function
'
)
{
let
type
=
editor
.
getEditorType
();
if
(
type
!==
editorCommon
.
EditorType
.
ICodeEditor
&&
type
!==
editorCommon
.
EditorType
.
IDiffEditor
)
{
continue
;
}
// Editor Settings (Code Editor, Diff, Terminal)
if
(
editor
&&
typeof
editor
.
updateOptions
===
'
function
'
)
{
let
type
=
editor
.
getEditorType
();
if
(
type
!==
editorCommon
.
EditorType
.
ICodeEditor
&&
type
!==
editorCommon
.
EditorType
.
IDiffEditor
)
{
return
;
}
let
editorConfig
=
config
[
EditorConfiguration
.
EDITOR_SECTION
];
if
(
type
===
editorCommon
.
EditorType
.
IDiffEditor
)
{
let
diffEditorConfig
=
config
[
EditorConfiguration
.
DIFF_EDITOR_SECTION
];
if
(
diffEditorConfig
)
{
if
(
!
editorConfig
)
{
editorConfig
=
diffEditorConfig
;
}
else
{
editorConfig
=
objects
.
mixin
(
editorConfig
,
diffEditorConfig
);
}
let
editorConfig
=
config
[
EditorConfiguration
.
EDITOR_SECTION
];
if
(
type
===
editorCommon
.
EditorType
.
IDiffEditor
)
{
let
diffEditorConfig
=
config
[
EditorConfiguration
.
DIFF_EDITOR_SECTION
];
if
(
diffEditorConfig
)
{
if
(
!
editorConfig
)
{
editorConfig
=
diffEditorConfig
;
}
else
{
editorConfig
=
objects
.
mixin
(
editorConfig
,
diffEditorConfig
);
}
}
}
if
(
editorConfig
)
{
delete
editorConfig
.
readOnly
;
// Prevent someone from making editor readonly
editor
.
updateOptions
(
editorConfig
);
}
if
(
editorConfig
)
{
delete
editorConfig
.
readOnly
;
// Prevent someone from making editor readonly
editor
.
updateOptions
(
editorConfig
);
}
}
}
...
...
src/vs/editor/common/services/modeService.ts
浏览文件 @
e466584a
...
...
@@ -47,7 +47,6 @@ export interface IModeService {
configureMode
(
modeName
:
string
,
options
:
any
):
void
;
configureModeById
(
modeId
:
string
,
options
:
any
):
void
;
configureAllModes
(
config
:
any
):
void
;
getConfigurationForMode
(
modeId
:
string
):
any
;
// --- reading
...
...
src/vs/editor/common/services/modeServiceImpl.ts
浏览文件 @
e466584a
...
...
@@ -192,7 +192,7 @@ export class ModeServiceImpl implements IModeService {
}
}
p
ublic
configureAllModes
(
config
:
any
):
void
{
p
rotected
_
configureAllModes
(
config
:
any
):
void
{
if
(
!
config
)
{
return
;
}
...
...
@@ -588,6 +588,9 @@ export class MainThreadModeServiceImpl extends ModeServiceImpl {
private
onConfigurationChange
(
configuration
:
IFilesConfiguration
):
void
{
// Update Languages
this
.
_configureAllModes
(
configuration
);
// Clear user configured mime associations
mime
.
clearTextMimes
(
true
/* user configured */
);
...
...
src/vs/editor/test/common/mocks/mockModeService.ts
浏览文件 @
e466584a
...
...
@@ -22,9 +22,6 @@ export class MockModeService implements IModeService {
configureModeById
(
modeId
:
string
,
options
:
any
):
void
{
throw
new
Error
(
'
Not implemented
'
);
}
configureAllModes
(
config
:
any
):
void
{
throw
new
Error
(
'
Not implemented
'
);
}
getConfigurationForMode
(
modeId
:
string
):
any
{
throw
new
Error
(
'
Not implemented
'
);
}
...
...
src/vs/workbench/browser/parts/editor/textEditor.ts
浏览文件 @
e466584a
...
...
@@ -9,7 +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
{
OptionsChangeEvent
,
EventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
import
{
EventType
as
WorkbenchEventType
}
from
'
vs/workbench/common/events
'
;
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
'
;
...
...
@@ -35,6 +35,7 @@ import {Selection} from 'vs/editor/common/core/selection';
export
abstract
class
BaseTextEditor
extends
BaseEditor
{
private
editorControl
:
IEditor
;
private
_editorContainer
:
Builder
;
private
_hasPendingConfigurationChange
=
false
;
constructor
(
id
:
string
,
...
...
@@ -51,10 +52,10 @@ export abstract class BaseTextEditor extends BaseEditor {
)
{
super
(
id
,
telemetryService
);
this
.
toUnbind
.
push
(
this
.
_eventService
.
addListener2
(
WorkbenchEventType
.
WORKBENCH_OPTIONS_CHANGED
,
(
e
)
=>
this
.
onOptionsChanged
(
e
)));
this
.
toUnbind
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
applyConfiguration
(
e
.
config
)));
this
.
toUnbind
.
push
(
this
.
_eventService
.
addListener2
(
WorkbenchEventType
.
WORKBENCH_OPTIONS_CHANGED
,
_
=>
this
.
handleConfigurationChangeEvent
(
)));
this
.
toUnbind
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
handleConfigurationChangeEvent
(
e
.
config
)));
this
.
toUnbind
.
push
(
_themeService
.
onDidThemeChange
(
_
=>
this
.
onThemeChanged
()));
this
.
toUnbind
.
push
(
_themeService
.
onDidThemeChange
(
_
=>
this
.
handleConfigurationChangeEvent
()));
}
public
get
instantiationService
():
IInstantiationService
{
...
...
@@ -73,31 +74,37 @@ export abstract class BaseTextEditor extends BaseEditor {
return
this
.
_messageService
;
}
protected
applyConfiguration
(
configuration
:
IFilesConfiguration
):
void
{
private
handleConfigurationChangeEvent
(
configuration
?:
any
):
void
{
if
(
this
.
isVisible
())
{
this
.
applyConfiguration
(
configuration
);
}
else
{
this
.
_hasPendingConfigurationChange
=
true
;
}
}
// Update Editor with configuration and editor settings
if
(
this
.
editorControl
)
{
private
consumePendingConfigurationChangeEvent
():
void
{
if
(
this
.
_hasPendingConfigurationChange
)
{
this
.
applyConfiguration
(
this
.
configurationService
.
getConfiguration
());
this
.
_hasPendingConfigurationChange
=
false
;
}
}
protected
applyConfiguration
(
configuration
?:
any
):
void
{
if
(
!
this
.
editorControl
)
{
return
;
}
if
(
configuration
)
{
// Update Editor with configuration and editor settings
let
specificEditorSettings
=
this
.
getCodeEditorOptions
();
configuration
=
objects
.
clone
(
configuration
);
// dont modify original config
objects
.
assign
(
configuration
[
EditorConfiguration
.
EDITOR_SECTION
],
specificEditorSettings
);
EditorConfiguration
.
apply
(
configuration
,
this
.
editorControl
);
}
// Update Languages
this
.
_modeService
.
configureAllModes
(
configuration
);
}
private
onOptionsChanged
(
event
:
OptionsChangeEvent
):
void
{
if
(
this
.
editorControl
)
{
}
else
{
this
.
editorControl
.
updateOptions
(
this
.
getCodeEditorOptions
());
}
}
private
onThemeChanged
():
void
{
this
.
editorControl
.
updateOptions
(
this
.
getCodeEditorOptions
());
}
protected
getCodeEditorOptions
():
IEditorOptions
{
let
baseOptions
:
IEditorOptions
=
{
overviewRulerLanes
:
3
,
...
...
@@ -150,6 +157,7 @@ export abstract class BaseTextEditor extends BaseEditor {
// Pass on to Editor
if
(
visible
)
{
this
.
consumePendingConfigurationChangeEvent
();
this
.
editorControl
.
onVisible
();
}
else
{
this
.
editorControl
.
onHide
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录