Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
566c8439
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
566c8439
编写于
2月 24, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
indentation: remeber indentation settings per model
fixes #3318
上级
fc168eab
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
10 deletion
+44
-10
src/vs/workbench/browser/parts/editor/editorStatus.ts
src/vs/workbench/browser/parts/editor/editorStatus.ts
+44
-10
未找到文件。
src/vs/workbench/browser/parts/editor/editorStatus.ts
浏览文件 @
566c8439
...
...
@@ -93,7 +93,11 @@ interface StateDelta {
mode
?:
string
;
encoding
?:
string
;
EOL
?:
string
;
indentation
?:
string
;
indentation
?:
{
modelId
:
string
;
insertSpaces
:
boolean
;
tabSize
:
number
;
};
tabFocusMode
?:
boolean
;
}
...
...
@@ -112,6 +116,8 @@ class State {
private
_indentation
:
string
;
public
get
indentation
():
string
{
return
this
.
_indentation
;
}
private
_indentationHistory
:
{
[
modelId
:
string
]:
{
insertSpaces
:
boolean
,
tabSize
:
number
}};
public
get
indentationHistory
():
{
[
modelId
:
string
]:
{
insertSpaces
:
boolean
,
tabSize
:
number
}}
{
return
this
.
_indentationHistory
;
}
private
_tabFocusMode
:
boolean
;
public
get
tabFocusMode
():
boolean
{
return
this
.
_tabFocusMode
;
}
...
...
@@ -122,6 +128,7 @@ class State {
this
.
_encoding
=
null
;
this
.
_EOL
=
null
;
this
.
_tabFocusMode
=
false
;
this
.
_indentationHistory
=
{};
}
public
update
(
update
:
StateDelta
):
IStateChange
{
...
...
@@ -143,8 +150,14 @@ class State {
}
}
if
(
typeof
update
.
indentation
!==
'
undefined
'
)
{
if
(
this
.
_indentation
!==
update
.
indentation
)
{
this
.
_indentation
=
update
.
indentation
;
let
indentationLabel
=
null
;
if
(
update
.
indentation
)
{
indentationLabel
=
update
.
indentation
.
insertSpaces
?
nls
.
localize
(
'
spacesSize
'
,
"
Spaces: {0}
"
,
update
.
indentation
.
tabSize
)
:
nls
.
localize
(
'
tabSize
'
,
"
Tab Size: {0}
"
,
update
.
indentation
.
tabSize
);
this
.
_indentationHistory
[
update
.
indentation
.
modelId
]
=
update
.
indentation
;
}
if
(
this
.
_indentation
!==
indentationLabel
)
{
this
.
_indentation
=
indentationLabel
;
somethingChanged
=
true
;
e
.
indentation
=
true
;
}
...
...
@@ -217,7 +230,8 @@ export class EditorStatus implements IStatusbarItem {
@
IQuickOpenService
private
quickOpenService
:
IQuickOpenService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IEventService
private
eventService
:
IEventService
,
@
IModeService
private
modeService
:
IModeService
@
IModeService
private
modeService
:
IModeService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
this
.
toDispose
=
[];
this
.
state
=
new
State
();
...
...
@@ -264,7 +278,7 @@ export class EditorStatus implements IStatusbarItem {
this
.
eventService
.
addListener2
(
EventType
.
TEXT_EDITOR_MODE_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onModeChange
(
e
.
editor
)),
this
.
eventService
.
addListener2
(
EventType
.
TEXT_EDITOR_CONTENT_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onEOLChange
(
e
.
editor
)),
this
.
eventService
.
addListener2
(
EventType
.
TEXT_EDITOR_CONFIGURATION_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onTabFocusModeChange
(
e
.
editor
)),
this
.
eventService
.
addListener2
(
EventType
.
TEXT_EDITOR_CONFIGURATION_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onIndentationChange
(
e
.
editor
))
this
.
eventService
.
addListener2
(
EventType
.
TEXT_EDITOR_CONFIGURATION_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onIndentationChange
(
e
.
editor
,
false
))
);
return
combinedDispose
(...
this
.
toDispose
);
...
...
@@ -395,7 +409,7 @@ export class EditorStatus implements IStatusbarItem {
this
.
onEOLChange
(
e
);
this
.
onEncodingChange
(
e
);
this
.
onTabFocusModeChange
(
e
);
this
.
onIndentationChange
(
e
);
this
.
onIndentationChange
(
e
,
true
);
}
private
onModeChange
(
e
:
IBaseEditor
):
void
{
...
...
@@ -423,7 +437,7 @@ export class EditorStatus implements IStatusbarItem {
this
.
updateState
(
info
);
}
private
onIndentationChange
(
e
:
IBaseEditor
):
void
{
private
onIndentationChange
(
e
:
IBaseEditor
,
inputChanged
:
boolean
):
void
{
if
(
e
&&
!
this
.
isActiveEditor
(
e
))
{
return
;
}
...
...
@@ -435,9 +449,29 @@ export class EditorStatus implements IStatusbarItem {
if
(
editorWidget
.
getEditorType
()
===
EditorType
.
IDiffEditor
)
{
editorWidget
=
(
<
IDiffEditor
>
editorWidget
).
getModifiedEditor
();
}
const
options
=
(
<
ICommonCodeEditor
>
editorWidget
).
getIndentationOptions
();
update
.
indentation
=
options
.
insertSpaces
?
nls
.
localize
(
'
spacesSize
'
,
"
Spaces: {0}
"
,
options
.
tabSize
)
:
nls
.
localize
(
'
tabSize
'
,
"
Tab Size: {0}
"
,
options
.
tabSize
);
const
model
=
(
<
ICommonCodeEditor
>
editorWidget
).
getModel
();
if
(
model
)
{
const
modelId
=
model
.
getAssociatedResource
().
toString
();
if
(
inputChanged
)
{
if
(
this
.
state
.
indentationHistory
[
modelId
])
{
editorWidget
.
updateOptions
(
this
.
state
.
indentationHistory
[
modelId
]);
}
else
{
this
.
configurationService
.
loadConfiguration
(
'
editor
'
).
done
(
config
=>
{
editorWidget
.
updateOptions
({
tabSize
:
config
.
tabSize
,
insertSpaces
:
config
.
insertSpaces
});
},
errors
.
onUnexpectedError
);
}
}
update
.
indentation
=
{
insertSpaces
:
(
<
ICommonCodeEditor
>
editorWidget
).
getIndentationOptions
().
insertSpaces
,
tabSize
:
(
<
ICommonCodeEditor
>
editorWidget
).
getIndentationOptions
().
tabSize
,
modelId
};
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录