Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d60cc73d
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,发现更多精彩内容 >>
提交
d60cc73d
编写于
12月 09, 2015
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #498 - indentation guessing defaults to insertSpaces: true, tabSize: 4 when not enough hints
上级
a7254919
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
12 deletion
+12
-12
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+1
-1
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+3
-3
src/vs/editor/test/common/model/textModel.test.ts
src/vs/editor/test/common/model/textModel.test.ts
+8
-8
未找到文件。
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
d60cc73d
...
...
@@ -505,7 +505,7 @@ export class CommonEditorConfiguration extends EventEmitter implements EditorCom
tabSizeIsAuto
:
false
,
tabSize
:
4
,
insertSpacesIsAuto
:
false
,
insertSpaces
:
fals
e
insertSpaces
:
tru
e
};
if
(
opts
.
tabSize
===
'
auto
'
)
{
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
d60cc73d
...
...
@@ -486,11 +486,11 @@ export class TextModel extends OrderGuaranteeEventEmitter implements EditorCommo
linesIndentedWithSpaces
+=
(
absoluteSpaceCounts
[
i
]
||
0
);
}
// Give preference to
tabs over space
s (when evidence is the same)
// Give preference to
spaces over tab
s (when evidence is the same)
// or when there are not enough clues (too little indentation in the file)
if
(
linesIndentedWithTabs
>=
linesIndentedWithSpaces
)
{
return
{
insertSpaces
:
fals
e
,
insertSpaces
:
tru
e
,
tabSize
:
defaultTabSize
};
}
...
...
@@ -498,7 +498,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements EditorCommo
if
(
linesWithIndentationCount
<
6
&&
linesIndentedWithTabs
>
0
)
{
// Making a guess with 6 indented lines, of which tabs are used besides spaces is very difficult
return
{
insertSpaces
:
fals
e
,
insertSpaces
:
tru
e
,
tabSize
:
defaultTabSize
};
}
...
...
src/vs/editor/test/common/model/textModel.test.ts
浏览文件 @
d60cc73d
...
...
@@ -11,14 +11,14 @@ import Position = require('vs/editor/common/core/position');
function
testGuessIndentation
(
expectedInsertSpaces
:
boolean
,
expectedTabSize
:
number
,
text
:
string
[],
msg
?:
string
):
void
{
var
m
=
new
TextModel
.
TextModel
([],
TextModel
.
TextModel
.
toRawText
(
text
.
join
(
'
\n
'
)));
var
r
=
m
.
guessIndentation
(
1
773
);
var
r
=
m
.
guessIndentation
(
1
337
);
m
.
dispose
();
assert
.
equal
(
r
.
insertSpaces
,
expectedInsertSpaces
,
msg
);
if
(
expectedInsertSpaces
)
{
assert
.
equal
(
r
.
tabSize
,
expectedTabSize
,
msg
);
}
else
{
assert
.
equal
(
r
.
tabSize
,
1
773
,
msg
);
assert
.
equal
(
r
.
tabSize
,
1
337
,
msg
);
}
}
...
...
@@ -64,26 +64,26 @@ suite('Editor Model - TextModel', () => {
test
(
'
guess indentation 1
'
,
()
=>
{
// Defaults to tabs
guesses
Tabs
(
[
guesses
Spaces
(
1337
,
[
'
x
'
,
'
x
'
]);
// Gives preference to tabs
guesses
Tabs
(
[
guesses
Spaces
(
1337
,
[
'
\t
x
'
,
'
x
'
]);
guesses
Tabs
(
[
guesses
Spaces
(
1337
,
[
'
\t
x
'
,
'
x
'
]);
guesses
Tabs
(
[
guesses
Spaces
(
1337
,
[
'
\t
x
'
,
'
x
'
]);
guesses
Tabs
(
[
guesses
Spaces
(
1337
,
[
'
x
'
,
'
x
'
,
'
x
'
,
...
...
@@ -93,7 +93,7 @@ suite('Editor Model - TextModel', () => {
'
x
'
,
'
x
'
],
'
7x1 - 1 space is never guessed as an indentation
'
);
guesses
Tabs
(
[
guesses
Spaces
(
1337
,
[
''
,
'
'
,
'
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录