Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
19291ef2
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,发现更多精彩内容 >>
提交
19291ef2
编写于
12月 07, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #16573: Ensure textEditor.options always contains all properties
上级
887f9c18
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
544 addition
and
36 deletion
+544
-36
extensions/vscode-api-tests/src/editor.test.ts
extensions/vscode-api-tests/src/editor.test.ts
+29
-1
src/vs/workbench/api/node/extHostEditors.ts
src/vs/workbench/api/node/extHostEditors.ts
+189
-12
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+0
-5
src/vs/workbench/api/node/mainThreadEditorsTracker.ts
src/vs/workbench/api/node/mainThreadEditorsTracker.ts
+9
-18
src/vs/workbench/test/node/api/extHostEditors.test.ts
src/vs/workbench/test/node/api/extHostEditors.test.ts
+317
-0
未找到文件。
extensions/vscode-api-tests/src/editor.test.ts
浏览文件 @
19291ef2
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
workspace
,
window
,
Position
,
Range
,
commands
,
TextEditor
,
TextDocument
}
from
'
vscode
'
;
import
{
workspace
,
window
,
Position
,
Range
,
commands
,
TextEditor
,
TextDocument
,
TextEditorCursorStyle
,
TextEditorLineNumbersStyle
}
from
'
vscode
'
;
import
{
createRandomFile
,
deleteFile
,
cleanUp
}
from
'
./utils
'
;
suite
(
'
editor tests
'
,
()
=>
{
...
...
@@ -98,4 +98,32 @@ suite('editor tests', () => {
});
});
});
test
(
'
issue #16573: Extension API: insertSpaces and tabSize are undefined
'
,
()
=>
{
return
withRandomFileEditor
(
'
Hello world!
\n\t
Hello world!
'
,
(
editor
,
doc
)
=>
{
assert
.
equal
(
editor
.
options
.
tabSize
,
4
);
assert
.
equal
(
editor
.
options
.
insertSpaces
,
false
);
assert
.
equal
(
editor
.
options
.
cursorStyle
,
TextEditorCursorStyle
.
Line
);
assert
.
equal
(
editor
.
options
.
lineNumbers
,
TextEditorLineNumbersStyle
.
On
);
editor
.
options
=
{
tabSize
:
2
};
assert
.
equal
(
editor
.
options
.
tabSize
,
2
);
assert
.
equal
(
editor
.
options
.
insertSpaces
,
false
);
assert
.
equal
(
editor
.
options
.
cursorStyle
,
TextEditorCursorStyle
.
Line
);
assert
.
equal
(
editor
.
options
.
lineNumbers
,
TextEditorLineNumbersStyle
.
On
);
editor
.
options
.
tabSize
=
'
invalid
'
;
assert
.
equal
(
editor
.
options
.
tabSize
,
2
);
assert
.
equal
(
editor
.
options
.
insertSpaces
,
false
);
assert
.
equal
(
editor
.
options
.
cursorStyle
,
TextEditorCursorStyle
.
Line
);
assert
.
equal
(
editor
.
options
.
lineNumbers
,
TextEditorLineNumbersStyle
.
On
);
return
Promise
.
resolve
();
});
});
});
src/vs/workbench/api/node/extHostEditors.ts
浏览文件 @
19291ef2
...
...
@@ -12,9 +12,9 @@ import Event, { Emitter } from 'vs/base/common/event';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
ExtHostDocuments
,
ExtHostDocumentData
}
from
'
vs/workbench/api/node/extHostDocuments
'
;
import
{
Selection
,
Range
,
Position
,
E
ditorOptions
,
EndOfLine
,
TextEditorRevealType
,
TextEditorSelectionChangeKind
}
from
'
./extHostTypes
'
;
import
{
ISingleEditOperation
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IResolvedTextEditorConfiguration
,
ISelectionChangeEvent
}
from
'
vs/workbench/api/node/mainThreadEditorsTracker
'
;
import
{
Selection
,
Range
,
Position
,
E
ndOfLine
,
TextEditorRevealType
,
TextEditorSelectionChangeKind
,
TextEditorLineNumbersStyle
}
from
'
./extHostTypes
'
;
import
{
ISingleEditOperation
,
TextEditorCursorStyle
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IResolvedTextEditorConfiguration
,
ISelectionChangeEvent
,
ITextEditorConfigurationUpdate
}
from
'
vs/workbench/api/node/mainThreadEditorsTracker
'
;
import
*
as
TypeConverters
from
'
./extHostTypeConverters
'
;
import
{
MainContext
,
MainThreadEditorsShape
,
ExtHostEditorsShape
,
ITextEditorAddData
,
ITextEditorPositionData
}
from
'
./extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -293,6 +293,180 @@ function deprecated(name: string, message: string = 'Refer to the documentation
};
}
export
class
ExtHostTextEditorOptions
implements
vscode
.
TextEditorOptions
{
private
_proxy
:
MainThreadEditorsShape
;
private
_id
:
string
;
private
_tabSize
:
number
;
private
_insertSpaces
:
boolean
;
private
_cursorStyle
:
TextEditorCursorStyle
;
private
_lineNumbers
:
TextEditorLineNumbersStyle
;
constructor
(
proxy
:
MainThreadEditorsShape
,
id
:
string
,
source
:
IResolvedTextEditorConfiguration
)
{
this
.
_proxy
=
proxy
;
this
.
_id
=
id
;
this
.
_accept
(
source
);
}
public
_accept
(
source
:
IResolvedTextEditorConfiguration
):
void
{
this
.
_tabSize
=
source
.
tabSize
;
this
.
_insertSpaces
=
source
.
insertSpaces
;
this
.
_cursorStyle
=
source
.
cursorStyle
;
this
.
_lineNumbers
=
source
.
lineNumbers
;
}
public
get
tabSize
():
number
|
string
{
return
this
.
_tabSize
;
}
private
_validateTabSize
(
value
:
number
|
string
):
number
|
'
auto
'
|
null
{
if
(
value
===
'
auto
'
)
{
return
'
auto
'
;
}
if
(
typeof
value
===
'
number
'
)
{
let
r
=
Math
.
floor
(
value
);
return
(
r
>
0
?
r
:
null
);
}
if
(
typeof
value
===
'
string
'
)
{
let
r
=
parseInt
(
value
,
10
);
if
(
isNaN
(
r
))
{
return
null
;
}
return
(
r
>
0
?
r
:
null
);
}
return
null
;
}
public
set
tabSize
(
value
:
number
|
string
)
{
let
tabSize
=
this
.
_validateTabSize
(
value
);
if
(
tabSize
===
null
)
{
// ignore invalid call
return
;
}
if
(
typeof
tabSize
===
'
number
'
)
{
if
(
this
.
_tabSize
===
tabSize
)
{
// nothing to do
return
;
}
// reflect the new tabSize value immediately
this
.
_tabSize
=
tabSize
;
}
warnOnError
(
this
.
_proxy
.
$trySetOptions
(
this
.
_id
,
{
tabSize
:
tabSize
}));
}
public
get
insertSpaces
():
boolean
|
string
{
return
this
.
_insertSpaces
;
}
private
_validateInsertSpaces
(
value
:
boolean
|
string
):
boolean
|
'
auto
'
{
if
(
value
===
'
auto
'
)
{
return
'
auto
'
;
}
return
(
value
===
'
false
'
?
false
:
Boolean
(
value
));
}
public
set
insertSpaces
(
value
:
boolean
|
string
)
{
let
insertSpaces
=
this
.
_validateInsertSpaces
(
value
);
if
(
typeof
insertSpaces
===
'
boolean
'
)
{
if
(
this
.
_insertSpaces
===
insertSpaces
)
{
// nothing to do
return
;
}
// reflect the new insertSpaces value immediately
this
.
_insertSpaces
=
insertSpaces
;
}
warnOnError
(
this
.
_proxy
.
$trySetOptions
(
this
.
_id
,
{
insertSpaces
:
insertSpaces
}));
}
public
get
cursorStyle
():
TextEditorCursorStyle
{
return
this
.
_cursorStyle
;
}
public
set
cursorStyle
(
value
:
TextEditorCursorStyle
)
{
if
(
this
.
_cursorStyle
===
value
)
{
// nothing to do
return
;
}
this
.
_cursorStyle
=
value
;
warnOnError
(
this
.
_proxy
.
$trySetOptions
(
this
.
_id
,
{
cursorStyle
:
value
}));
}
public
get
lineNumbers
():
TextEditorLineNumbersStyle
{
return
this
.
_lineNumbers
;
}
public
set
lineNumbers
(
value
:
TextEditorLineNumbersStyle
)
{
if
(
this
.
_lineNumbers
===
value
)
{
// nothing to do
return
;
}
this
.
_lineNumbers
=
value
;
warnOnError
(
this
.
_proxy
.
$trySetOptions
(
this
.
_id
,
{
lineNumbers
:
value
}));
}
public
assign
(
newOptions
:
vscode
.
TextEditorOptions
)
{
let
bulkConfigurationUpdate
:
ITextEditorConfigurationUpdate
=
{};
let
hasUpdate
=
false
;
if
(
typeof
newOptions
.
tabSize
!==
'
undefined
'
)
{
let
tabSize
=
this
.
_validateTabSize
(
newOptions
.
tabSize
);
if
(
tabSize
===
'
auto
'
)
{
hasUpdate
=
true
;
bulkConfigurationUpdate
.
tabSize
=
tabSize
;
}
else
if
(
typeof
tabSize
===
'
number
'
&&
this
.
_tabSize
!==
tabSize
)
{
// reflect the new tabSize value immediately
this
.
_tabSize
=
tabSize
;
hasUpdate
=
true
;
bulkConfigurationUpdate
.
tabSize
=
tabSize
;
}
}
if
(
typeof
newOptions
.
insertSpaces
!==
'
undefined
'
)
{
let
insertSpaces
=
this
.
_validateInsertSpaces
(
newOptions
.
insertSpaces
);
if
(
insertSpaces
===
'
auto
'
)
{
hasUpdate
=
true
;
bulkConfigurationUpdate
.
insertSpaces
=
insertSpaces
;
}
else
if
(
this
.
_insertSpaces
!==
insertSpaces
)
{
// reflect the new insertSpaces value immediately
this
.
_insertSpaces
=
insertSpaces
;
hasUpdate
=
true
;
bulkConfigurationUpdate
.
insertSpaces
=
insertSpaces
;
}
}
if
(
typeof
newOptions
.
cursorStyle
!==
'
undefined
'
)
{
if
(
this
.
_cursorStyle
!==
newOptions
.
cursorStyle
)
{
this
.
_cursorStyle
=
newOptions
.
cursorStyle
;
hasUpdate
=
true
;
bulkConfigurationUpdate
.
cursorStyle
=
newOptions
.
cursorStyle
;
}
}
if
(
typeof
newOptions
.
lineNumbers
!==
'
undefined
'
)
{
if
(
this
.
_lineNumbers
!==
newOptions
.
lineNumbers
)
{
this
.
_lineNumbers
=
newOptions
.
lineNumbers
;
hasUpdate
=
true
;
bulkConfigurationUpdate
.
lineNumbers
=
newOptions
.
lineNumbers
;
}
}
if
(
hasUpdate
)
{
warnOnError
(
this
.
_proxy
.
$trySetOptions
(
this
.
_id
,
bulkConfigurationUpdate
));
}
}
}
class
ExtHostTextEditor
implements
vscode
.
TextEditor
{
private
_proxy
:
MainThreadEditorsShape
;
...
...
@@ -300,15 +474,15 @@ class ExtHostTextEditor implements vscode.TextEditor {
private
_documentData
:
ExtHostDocumentData
;
private
_selections
:
Selection
[];
private
_options
:
vscode
.
TextEditorOptions
;
private
_options
:
ExtHost
TextEditorOptions
;
private
_viewColumn
:
vscode
.
ViewColumn
;
constructor
(
proxy
:
MainThreadEditorsShape
,
id
:
string
,
document
:
ExtHostDocumentData
,
selections
:
Selection
[],
options
:
EditorOptions
,
viewColumn
:
vscode
.
ViewColumn
)
{
constructor
(
proxy
:
MainThreadEditorsShape
,
id
:
string
,
document
:
ExtHostDocumentData
,
selections
:
Selection
[],
options
:
IResolvedTextEditorConfiguration
,
viewColumn
:
vscode
.
ViewColumn
)
{
this
.
_proxy
=
proxy
;
this
.
_id
=
id
;
this
.
_documentData
=
document
;
this
.
_selections
=
selections
;
this
.
_options
=
options
;
this
.
_options
=
new
ExtHostTextEditorOptions
(
this
.
_proxy
,
this
.
_id
,
options
)
;
this
.
_viewColumn
=
viewColumn
;
}
...
...
@@ -341,14 +515,11 @@ class ExtHostTextEditor implements vscode.TextEditor {
}
set
options
(
value
:
vscode
.
TextEditorOptions
)
{
this
.
_options
=
value
;
this
.
_runOnProxy
(()
=>
{
return
this
.
_proxy
.
$trySetOptions
(
this
.
_id
,
this
.
_options
);
},
true
);
this
.
_options
.
assign
(
value
);
}
_acceptOptions
(
options
:
EditorOptions
):
void
{
this
.
_options
=
options
;
_acceptOptions
(
options
:
IResolvedTextEditorConfiguration
):
void
{
this
.
_options
.
_accept
(
options
)
;
}
// ---- view column
...
...
@@ -460,3 +631,9 @@ class ExtHostTextEditor implements vscode.TextEditor {
});
}
}
function
warnOnError
(
promise
:
TPromise
<
any
>
):
void
{
promise
.
then
(
null
,
(
err
)
=>
{
console
.
warn
(
err
);
});
}
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
19291ef2
...
...
@@ -37,11 +37,6 @@ export class Disposable {
}
}
export
interface
EditorOptions
{
tabSize
:
number
|
string
;
insertSpaces
:
boolean
|
string
;
}
export
class
Position
{
static
Min
(...
positions
:
Position
[]):
Position
{
...
...
src/vs/workbench/api/node/mainThreadEditorsTracker.ts
浏览文件 @
19291ef2
...
...
@@ -17,8 +17,8 @@ import { Selection } from 'vs/editor/common/core/selection';
import
{
EndOfLine
,
TextEditorLineNumbersStyle
}
from
'
vs/workbench/api/node/extHostTypes
'
;
export
interface
ITextEditorConfigurationUpdate
{
tabSize
?:
number
|
string
;
insertSpaces
?:
boolean
|
string
;
tabSize
?:
number
|
'
auto
'
;
insertSpaces
?:
boolean
|
'
auto
'
;
cursorStyle
?:
EditorCommon
.
TextEditorCursorStyle
;
lineNumbers
?:
TextEditorLineNumbersStyle
;
}
...
...
@@ -209,18 +209,12 @@ export class MainThreadTextEditor {
let
insertSpaces
=
creationOpts
.
insertSpaces
;
let
tabSize
=
creationOpts
.
tabSize
;
if
(
newConfiguration
.
insertSpaces
!==
'
auto
'
)
{
if
(
typeof
newConfiguration
.
insertSpaces
!==
'
undefined
'
)
{
insertSpaces
=
(
newConfiguration
.
insertSpaces
===
'
false
'
?
false
:
Boolean
(
newConfiguration
.
insertSpaces
));
}
if
(
newConfiguration
.
insertSpaces
!==
'
auto
'
&&
typeof
newConfiguration
.
insertSpaces
!==
'
undefined
'
)
{
insertSpaces
=
newConfiguration
.
insertSpaces
;
}
if
(
newConfiguration
.
tabSize
!==
'
auto
'
)
{
if
(
typeof
newConfiguration
.
tabSize
!==
'
undefined
'
)
{
let
parsedTabSize
=
parseInt
(
<
string
>
newConfiguration
.
tabSize
,
10
);
if
(
!
isNaN
(
parsedTabSize
))
{
tabSize
=
parsedTabSize
;
}
}
if
(
newConfiguration
.
tabSize
!==
'
auto
'
&&
typeof
newConfiguration
.
tabSize
!==
'
undefined
'
)
{
tabSize
=
newConfiguration
.
tabSize
;
}
this
.
_model
.
detectIndentation
(
insertSpaces
,
tabSize
);
...
...
@@ -229,13 +223,10 @@ export class MainThreadTextEditor {
let
newOpts
:
EditorCommon
.
ITextModelUpdateOptions
=
{};
if
(
typeof
newConfiguration
.
insertSpaces
!==
'
undefined
'
)
{
newOpts
.
insertSpaces
=
(
newConfiguration
.
insertSpaces
===
'
false
'
?
false
:
Boolean
(
newConfiguration
.
insertSpaces
))
;
newOpts
.
insertSpaces
=
newConfiguration
.
insertSpaces
;
}
if
(
typeof
newConfiguration
.
tabSize
!==
'
undefined
'
)
{
let
parsedTabSize
=
parseInt
(
<
string
>
newConfiguration
.
tabSize
,
10
);
if
(
!
isNaN
(
parsedTabSize
))
{
newOpts
.
tabSize
=
parsedTabSize
;
}
newOpts
.
tabSize
=
newConfiguration
.
tabSize
;
}
this
.
_model
.
updateOptions
(
newOpts
);
}
...
...
src/vs/workbench/test/node/api/extHostEditors.test.ts
0 → 100644
浏览文件 @
19291ef2
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TextEditorLineNumbersStyle
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
TextEditorCursorStyle
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IResolvedTextEditorConfiguration
,
ITextEditorConfigurationUpdate
}
from
'
vs/workbench/api/node/mainThreadEditorsTracker
'
;
import
{
MainThreadEditorsShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
ExtHostTextEditorOptions
}
from
'
vs/workbench/api/node/extHostEditors
'
;
suite
(
'
ExtHostTextEditorOptions
'
,
()
=>
{
let
opts
:
ExtHostTextEditorOptions
;
let
calls
:
ITextEditorConfigurationUpdate
[]
=
[];
setup
(()
=>
{
calls
=
[];
let
mockProxy
:
MainThreadEditorsShape
=
{
$trySetOptions
:
(
id
:
string
,
options
:
ITextEditorConfigurationUpdate
)
=>
{
assert
.
equal
(
id
,
'
1
'
);
calls
.
push
(
options
);
return
TPromise
.
as
(
void
0
);
},
$tryShowTextDocument
:
undefined
,
$registerTextEditorDecorationType
:
undefined
,
$removeTextEditorDecorationType
:
undefined
,
$tryShowEditor
:
undefined
,
$tryHideEditor
:
undefined
,
$trySetDecorations
:
undefined
,
$tryRevealRange
:
undefined
,
$trySetSelections
:
undefined
,
$tryApplyEdits
:
undefined
,
};
opts
=
new
ExtHostTextEditorOptions
(
mockProxy
,
'
1
'
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
});
teardown
(()
=>
{
opts
=
null
;
calls
=
null
;
});
function
assertState
(
opts
:
ExtHostTextEditorOptions
,
expected
:
IResolvedTextEditorConfiguration
):
void
{
let
actual
=
{
tabSize
:
opts
.
tabSize
,
insertSpaces
:
opts
.
insertSpaces
,
cursorStyle
:
opts
.
cursorStyle
,
lineNumbers
:
opts
.
lineNumbers
};
assert
.
deepEqual
(
actual
,
expected
);
}
test
(
'
can set tabSize to the same value
'
,
()
=>
{
opts
.
tabSize
=
4
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can change tabSize to positive integer
'
,
()
=>
{
opts
.
tabSize
=
1
;
assertState
(
opts
,
{
tabSize
:
1
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
tabSize
:
1
}]);
});
test
(
'
can change tabSize to positive float
'
,
()
=>
{
opts
.
tabSize
=
2.3
;
assertState
(
opts
,
{
tabSize
:
2
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
tabSize
:
2
}]);
});
test
(
'
can change tabSize to a string number
'
,
()
=>
{
opts
.
tabSize
=
'
2
'
;
assertState
(
opts
,
{
tabSize
:
2
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
tabSize
:
2
}]);
});
test
(
'
tabSize can request indentation detection
'
,
()
=>
{
opts
.
tabSize
=
'
auto
'
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
tabSize
:
'
auto
'
}]);
});
test
(
'
ignores invalid tabSize 1
'
,
()
=>
{
opts
.
tabSize
=
null
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
ignores invalid tabSize 2
'
,
()
=>
{
opts
.
tabSize
=
-
5
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
ignores invalid tabSize 3
'
,
()
=>
{
opts
.
tabSize
=
'
hello
'
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
ignores invalid tabSize 4
'
,
()
=>
{
opts
.
tabSize
=
'
-17
'
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can set insertSpaces to the same value
'
,
()
=>
{
opts
.
insertSpaces
=
false
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can set insertSpaces to boolean
'
,
()
=>
{
opts
.
insertSpaces
=
true
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
true
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
insertSpaces
:
true
}]);
});
test
(
'
can set insertSpaces to false string
'
,
()
=>
{
opts
.
insertSpaces
=
'
false
'
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can set insertSpaces to truey
'
,
()
=>
{
opts
.
insertSpaces
=
'
hello
'
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
true
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
insertSpaces
:
true
}]);
});
test
(
'
insertSpaces can request indentation detection
'
,
()
=>
{
opts
.
insertSpaces
=
'
auto
'
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
insertSpaces
:
'
auto
'
}]);
});
test
(
'
can set cursorStyle to same value
'
,
()
=>
{
opts
.
cursorStyle
=
TextEditorCursorStyle
.
Line
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can change cursorStyle
'
,
()
=>
{
opts
.
cursorStyle
=
TextEditorCursorStyle
.
Block
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Block
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
cursorStyle
:
TextEditorCursorStyle
.
Block
}]);
});
test
(
'
can set lineNumbers to same value
'
,
()
=>
{
opts
.
lineNumbers
=
TextEditorLineNumbersStyle
.
On
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can change lineNumbers
'
,
()
=>
{
opts
.
lineNumbers
=
TextEditorLineNumbersStyle
.
Off
;
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
Off
});
assert
.
deepEqual
(
calls
,
[{
lineNumbers
:
TextEditorLineNumbersStyle
.
Off
}]);
});
test
(
'
can do bulk updates 0
'
,
()
=>
{
opts
.
assign
({
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[]);
});
test
(
'
can do bulk updates 1
'
,
()
=>
{
opts
.
assign
({
tabSize
:
'
auto
'
,
insertSpaces
:
true
});
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
true
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
tabSize
:
'
auto
'
,
insertSpaces
:
true
}]);
});
test
(
'
can do bulk updates 2
'
,
()
=>
{
opts
.
assign
({
tabSize
:
3
,
insertSpaces
:
'
auto
'
});
assertState
(
opts
,
{
tabSize
:
3
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Line
,
lineNumbers
:
TextEditorLineNumbersStyle
.
On
});
assert
.
deepEqual
(
calls
,
[{
tabSize
:
3
,
insertSpaces
:
'
auto
'
}]);
});
test
(
'
can do bulk updates 3
'
,
()
=>
{
opts
.
assign
({
cursorStyle
:
TextEditorCursorStyle
.
Block
,
lineNumbers
:
TextEditorLineNumbersStyle
.
Relative
});
assertState
(
opts
,
{
tabSize
:
4
,
insertSpaces
:
false
,
cursorStyle
:
TextEditorCursorStyle
.
Block
,
lineNumbers
:
TextEditorLineNumbersStyle
.
Relative
});
assert
.
deepEqual
(
calls
,
[{
cursorStyle
:
TextEditorCursorStyle
.
Block
,
lineNumbers
:
TextEditorLineNumbersStyle
.
Relative
}]);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录