Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2c6d4ad1
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,发现更多精彩内容 >>
提交
2c6d4ad1
编写于
2月 27, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #10339: Fix invocations of formatter to pass indentSize
上级
3bf1e49c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
31 deletion
+35
-31
src/vs/editor/common/model.ts
src/vs/editor/common/model.ts
+7
-1
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+8
-1
src/vs/editor/contrib/format/formatActions.ts
src/vs/editor/contrib/format/formatActions.ts
+19
-27
src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts
...rkbench/api/electron-browser/mainThreadSaveParticipant.ts
+1
-2
未找到文件。
src/vs/editor/common/model.ts
浏览文件 @
2c6d4ad1
...
...
@@ -12,7 +12,7 @@ import { IRange, Range } from 'vs/editor/common/core/range';
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
IModelContentChange
,
IModelContentChangedEvent
,
IModelDecorationsChangedEvent
,
IModelLanguageChangedEvent
,
IModelLanguageConfigurationChangedEvent
,
IModelOptionsChangedEvent
,
IModelTokensChangedEvent
,
ModelRawContentChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
SearchData
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
LanguageId
,
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageId
,
LanguageIdentifier
,
FormattingOptions
}
from
'
vs/editor/common/modes
'
;
import
{
ITextSnapshot
}
from
'
vs/platform/files/common/files
'
;
import
{
ThemeColor
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -500,6 +500,12 @@ export interface ITextModel {
*/
getOptions
():
TextModelResolvedOptions
;
/**
* Get the formatting options for this model.
* @internal
*/
getFormattingOptions
():
FormattingOptions
;
/**
* Get the current version id of the model.
* Anytime a change happens to the model (even undo/redo),
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
2c6d4ad1
...
...
@@ -25,7 +25,7 @@ import { IModelContentChangedEvent, IModelDecorationsChangedEvent, IModelLanguag
import
{
SearchData
,
SearchParams
,
TextModelSearch
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
ModelLinesTokens
,
ModelTokensChangedEventBuilder
}
from
'
vs/editor/common/model/textModelTokens
'
;
import
{
getWordAtText
}
from
'
vs/editor/common/model/wordHelper
'
;
import
{
IState
,
LanguageId
,
LanguageIdentifier
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IState
,
LanguageId
,
LanguageIdentifier
,
TokenizationRegistry
,
FormattingOptions
}
from
'
vs/editor/common/modes
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
NULL_LANGUAGE_IDENTIFIER
}
from
'
vs/editor/common/modes/nullMode
'
;
import
{
ignoreBracketsInToken
}
from
'
vs/editor/common/modes/supports
'
;
...
...
@@ -590,6 +590,13 @@ export class TextModel extends Disposable implements model.ITextModel {
return
this
.
_options
;
}
public
getFormattingOptions
():
FormattingOptions
{
return
{
tabSize
:
this
.
_options
.
indentSize
,
insertSpaces
:
this
.
_options
.
insertSpaces
};
}
public
updateOptions
(
_newOpts
:
model
.
ITextModelUpdateOptions
):
void
{
this
.
_assertNotDisposed
();
let
tabSize
=
(
typeof
_newOpts
.
tabSize
!==
'
undefined
'
)
?
_newOpts
.
tabSize
:
this
.
_options
.
tabSize
;
...
...
src/vs/editor/contrib/format/formatActions.ts
浏览文件 @
2c6d4ad1
...
...
@@ -213,34 +213,30 @@ class FormatOnType implements editorCommon.IEditorContribution {
});
let
modelOpts
=
model
.
getOptions
();
getOnTypeFormattingEdits
(
this
.
_telemetryService
,
this
.
_workerService
,
model
,
position
,
ch
,
{
tabSize
:
modelOpts
.
tabSize
,
insertSpaces
:
modelOpts
.
insertSpaces
}).
then
(
edits
=>
{
model
.
getFormattingOptions
()
).
then
(
edits
=>
{
unbind
.
dispose
();
unbind
.
dispose
();
if
(
canceled
)
{
return
;
}
if
(
canceled
)
{
return
;
}
if
(
isNonEmptyArray
(
edits
))
{
FormattingEdit
.
execute
(
this
.
_editor
,
edits
);
alertFormattingEdits
(
edits
);
}
if
(
isNonEmptyArray
(
edits
))
{
FormattingEdit
.
execute
(
this
.
_editor
,
edits
);
alertFormattingEdits
(
edits
);
}
},
(
err
)
=>
{
unbind
.
dispose
();
throw
err
;
});
},
(
err
)
=>
{
unbind
.
dispose
();
throw
err
;
});
}
public
getId
():
string
{
...
...
@@ -311,8 +307,7 @@ class FormatOnPaste implements editorCommon.IEditorContribution {
}
const
model
=
this
.
editor
.
getModel
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
formatDocumentRange
(
this
.
telemetryService
,
this
.
workerService
,
this
.
editor
,
range
,
{
tabSize
,
insertSpaces
},
CancellationToken
.
None
);
formatDocumentRange
(
this
.
telemetryService
,
this
.
workerService
,
this
.
editor
,
range
,
model
.
getFormattingOptions
(),
CancellationToken
.
None
);
}
public
getId
():
string
{
...
...
@@ -354,8 +349,7 @@ export class FormatDocumentAction extends EditorAction {
}
const
workerService
=
accessor
.
get
(
IEditorWorkerService
);
const
telemetryService
=
accessor
.
get
(
ITelemetryService
);
const
{
tabSize
,
insertSpaces
}
=
editor
.
getModel
().
getOptions
();
return
formatDocument
(
telemetryService
,
workerService
,
editor
,
{
tabSize
,
insertSpaces
},
CancellationToken
.
None
);
return
formatDocument
(
telemetryService
,
workerService
,
editor
,
editor
.
getModel
().
getFormattingOptions
(),
CancellationToken
.
None
);
}
}
...
...
@@ -386,8 +380,7 @@ export class FormatSelectionAction extends EditorAction {
}
const
workerService
=
accessor
.
get
(
IEditorWorkerService
);
const
telemetryService
=
accessor
.
get
(
ITelemetryService
);
const
{
tabSize
,
insertSpaces
}
=
editor
.
getModel
().
getOptions
();
return
formatDocumentRange
(
telemetryService
,
workerService
,
editor
,
FormatRangeType
.
Selection
,
{
tabSize
,
insertSpaces
},
CancellationToken
.
None
);
return
formatDocumentRange
(
telemetryService
,
workerService
,
editor
,
FormatRangeType
.
Selection
,
editor
.
getModel
().
getFormattingOptions
(),
CancellationToken
.
None
);
}
}
...
...
@@ -403,13 +396,12 @@ CommandsRegistry.registerCommand('editor.action.format', accessor => {
if
(
!
editor
||
!
editor
.
hasModel
())
{
return
undefined
;
}
const
{
tabSize
,
insertSpaces
}
=
editor
.
getModel
().
getOptions
();
const
workerService
=
accessor
.
get
(
IEditorWorkerService
);
const
telemetryService
=
accessor
.
get
(
ITelemetryService
);
if
(
editor
.
getSelection
().
isEmpty
())
{
return
formatDocument
(
telemetryService
,
workerService
,
editor
,
{
tabSize
,
insertSpaces
}
,
CancellationToken
.
None
);
return
formatDocument
(
telemetryService
,
workerService
,
editor
,
editor
.
getModel
().
getFormattingOptions
()
,
CancellationToken
.
None
);
}
else
{
return
formatDocumentRange
(
telemetryService
,
workerService
,
editor
,
FormatRangeType
.
Selection
,
{
tabSize
,
insertSpaces
}
,
CancellationToken
.
None
);
return
formatDocumentRange
(
telemetryService
,
workerService
,
editor
,
FormatRangeType
.
Selection
,
editor
.
getModel
().
getFormattingOptions
()
,
CancellationToken
.
None
);
}
});
src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts
浏览文件 @
2c6d4ad1
...
...
@@ -231,13 +231,12 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
}
const
versionNow
=
model
.
getVersionId
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
const
timeout
=
this
.
_configurationService
.
getValue
<
number
>
(
'
editor.formatOnSaveTimeout
'
,
{
overrideIdentifier
:
model
.
getLanguageIdentifier
().
language
,
resource
:
editorModel
.
getResource
()
});
return
new
Promise
<
ISingleEditOperation
[]
|
null
|
undefined
>
((
resolve
,
reject
)
=>
{
let
source
=
new
CancellationTokenSource
();
let
request
=
getDocumentFormattingEdits
(
this
.
_telemetryService
,
this
.
_editorWorkerService
,
model
,
{
tabSize
,
insertSpaces
}
,
FormatMode
.
Auto
,
source
.
token
);
let
request
=
getDocumentFormattingEdits
(
this
.
_telemetryService
,
this
.
_editorWorkerService
,
model
,
model
.
getFormattingOptions
()
,
FormatMode
.
Auto
,
source
.
token
);
setTimeout
(()
=>
{
reject
(
localize
(
'
timeout.formatOnSave
'
,
"
Aborted format on save after {0}ms
"
,
timeout
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录