Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8ad23858
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,发现更多精彩内容 >>
提交
8ad23858
编写于
6月 21, 2018
作者:
J
Jackson Kearl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests and bug fixes
上级
7be7e2f8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
167 addition
and
14 deletion
+167
-14
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+1
-1
src/vs/editor/common/controller/cursorDeleteOperations.ts
src/vs/editor/common/controller/cursorDeleteOperations.ts
+1
-1
src/vs/editor/common/controller/cursorTypeOperations.ts
src/vs/editor/common/controller/cursorTypeOperations.ts
+4
-4
src/vs/editor/test/browser/controller/cursor.test.ts
src/vs/editor/test/browser/controller/cursor.test.ts
+161
-8
未找到文件。
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
8ad23858
...
...
@@ -1600,7 +1600,7 @@ export class EditorOptionsValidator {
const
_autoClosingOptions
=
(
config
:
any
,
defaultValue
:
EditorAutoClosingOptions
):
EditorAutoClosingOptions
=>
{
if
(
typeof
config
===
'
boolean
'
)
{
return
{
autoClose
:
config
,
autoWrap
:
config
,
enabledBefore
:
'
\t\n
'
};
}
if
(
!
config
)
{
config
=
{};
}
let
copy
:
EditorAutoClosingOptions
=
{
autoClose
:
defaultValue
.
autoClose
,
autoWrap
:
defaultValue
.
autoWrap
,
enabledBefore
:
defaultValue
.
enabledBefore
};
if
(
typeof
config
.
autoClose
===
'
boolean
'
)
{
copy
.
autoClose
=
config
.
autoClose
;
}
if
(
typeof
config
.
autoWrap
===
'
boolean
'
)
{
copy
.
autoWrap
=
config
.
autoWrap
;
}
...
...
src/vs/editor/common/controller/cursorDeleteOperations.ts
浏览文件 @
8ad23858
...
...
@@ -65,7 +65,7 @@ export class DeleteOperations {
const
lineText
=
model
.
getLineContent
(
position
.
lineNumber
);
const
character
=
lineText
[
position
.
column
-
2
];
const
characterIsQuote
=
(
character
===
'
\'
'
||
character
===
'
"
'
);
const
characterIsQuote
=
(
character
===
'
\'
'
||
character
===
'
"
'
||
character
===
'
`
'
);
const
autoCloseConfig
=
characterIsQuote
?
config
.
autoClosingQuotes
:
config
.
autoClosingBrackets
;
if
(
!
config
.
autoClosingPairsOpen
.
hasOwnProperty
(
character
)
||
!
(
autoCloseConfig
.
autoWrap
||
autoCloseConfig
.
autoClose
))
{
...
...
src/vs/editor/common/controller/cursorTypeOperations.ts
浏览文件 @
8ad23858
...
...
@@ -437,7 +437,7 @@ export class TypeOperations {
}
private
static
_isAutoClosingCloseCharType
(
config
:
CursorConfiguration
,
model
:
ITextModel
,
selections
:
Selection
[],
ch
:
string
):
boolean
{
const
chIsQuote
=
(
ch
===
'
\'
'
||
ch
===
'
"
'
);
const
chIsQuote
=
(
ch
===
'
\'
'
||
ch
===
'
"
'
||
ch
===
'
`
'
);
const
autoCloseConfig
=
chIsQuote
?
config
.
autoClosingQuotes
:
config
.
autoClosingBrackets
;
if
(
!
autoCloseConfig
.
autoClose
||
!
config
.
autoClosingPairsClose
.
hasOwnProperty
(
ch
))
{
...
...
@@ -514,7 +514,7 @@ export class TypeOperations {
}
private
static
_isAutoClosingOpenCharType
(
config
:
CursorConfiguration
,
model
:
ITextModel
,
selections
:
Selection
[],
ch
:
string
):
boolean
{
const
chIsQuote
=
(
ch
===
'
\'
'
||
ch
===
'
"
'
);
const
chIsQuote
=
(
ch
===
'
\'
'
||
ch
===
'
"
'
||
ch
===
'
`
'
);
const
autoCloseConfig
=
chIsQuote
?
config
.
autoClosingQuotes
:
config
.
autoClosingBrackets
;
if
(
!
autoCloseConfig
.
autoClose
||
!
config
.
autoClosingPairsOpen
.
hasOwnProperty
(
ch
))
{
return
false
;
...
...
@@ -587,7 +587,7 @@ export class TypeOperations {
}
private
static
_isSurroundSelectionType
(
config
:
CursorConfiguration
,
model
:
ITextModel
,
selections
:
Selection
[],
ch
:
string
):
boolean
{
const
chIsQuote
=
(
ch
===
'
\'
'
||
ch
===
'
"
'
);
const
chIsQuote
=
(
ch
===
'
\'
'
||
ch
===
'
"
'
||
ch
===
'
`
'
);
const
autoCloseConfig
=
chIsQuote
?
config
.
autoClosingQuotes
:
config
.
autoClosingBrackets
;
if
(
!
autoCloseConfig
.
autoWrap
||
!
config
.
surroundingPairs
.
hasOwnProperty
(
ch
))
{
return
false
;
...
...
@@ -620,7 +620,7 @@ export class TypeOperations {
if
(
chIsQuote
&&
selection
.
startLineNumber
===
selection
.
endLineNumber
&&
selection
.
startColumn
+
1
===
selection
.
endColumn
)
{
const
selectionText
=
model
.
getValueInRange
(
selection
);
if
((
selectionText
===
'
\'
'
||
selectionText
===
'
"
'
))
{
if
((
selectionText
===
'
\'
'
||
selectionText
===
'
"
'
||
selectionText
===
'
`
'
))
{
// Typing a quote character on top of another quote character
// => disable surround selection type
return
false
;
...
...
src/vs/editor/test/browser/controller/cursor.test.ts
浏览文件 @
8ad23858
...
...
@@ -3999,14 +3999,14 @@ suite('autoClosingPairs', () => {
},
(
model
,
cursor
)
=>
{
let
autoClosePositions
=
[
'
var| a| =| [|];|
'
,
'
var| b| =| `asd`;|
'
,
'
var| c| =|
\'
asd
\'
;|
'
,
'
var| d| =| "asd";|
'
,
'
var| e| =| /*3*/| 3;|
'
,
'
var| f| =| /**| 3| */3;|
'
,
'
var| g| =| (3+5|);|
'
,
'
var| h| =| {| a
:|
\'
value
\'
| |}
;|
'
,
'
var| a| =| [|]
|
;|
'
,
'
var| b| =| `asd`
|
;|
'
,
'
var| c| =|
\'
asd
\'
|
;|
'
,
'
var| d| =| "asd"
|
;|
'
,
'
var| e| =| /*3*/| 3
|
;|
'
,
'
var| f| =| /**| 3| */3
|
;|
'
,
'
var| g| =| (3+5|)
|
;|
'
,
'
var| h| =| {| a
|:|
\'
value
\'
| |}|
;|
'
,
];
for
(
let
i
=
0
,
len
=
autoClosePositions
.
length
;
i
<
len
;
i
++
)
{
const
lineNumber
=
i
+
1
;
...
...
@@ -4025,6 +4025,159 @@ suite('autoClosingPairs', () => {
mode
.
dispose
();
});
test
(
'
configurable open parens
'
,
()
=>
{
let
mode
=
new
AutoClosingMode
();
usingCursor
({
text
:
[
'
var a = [];
'
,
'
var b = `asd`;
'
,
'
var c =
\'
asd
\'
;
'
,
'
var d = "asd";
'
,
'
var e = /*3*/ 3;
'
,
'
var f = /** 3 */3;
'
,
'
var g = (3+5);
'
,
'
var h = { a:
\'
value
\'
};
'
,
],
languageIdentifier
:
mode
.
getLanguageIdentifier
(),
editorOpts
:
{
autoClosingBrackets
:
{
enabledBefore
:
'
abc
'
,
autoClose
:
true
,
autoWrap
:
true
}
}
},
(
model
,
cursor
)
=>
{
let
autoClosePositions
=
[
'
v|ar |a = [|];|
'
,
'
v|ar |b = `|asd`;|
'
,
'
v|ar |c =
\'
|asd
\'
;|
'
,
'
v|ar d = "|asd";|
'
,
'
v|ar e = /*3*/ 3;|
'
,
'
v|ar f = /** 3 */3;|
'
,
'
v|ar g = (3+5|);|
'
,
'
v|ar h = { |a:
\'
v|alue
\'
|};|
'
,
];
for
(
let
i
=
0
,
len
=
autoClosePositions
.
length
;
i
<
len
;
i
++
)
{
const
lineNumber
=
i
+
1
;
const
autoCloseColumns
=
extractSpecialColumns
(
model
.
getLineMaxColumn
(
lineNumber
),
autoClosePositions
[
i
]);
for
(
let
column
=
1
;
column
<
autoCloseColumns
.
length
;
column
++
)
{
model
.
forceTokenization
(
lineNumber
);
if
(
autoCloseColumns
[
column
]
===
ColumnType
.
Special1
)
{
assertType
(
model
,
cursor
,
lineNumber
,
column
,
'
(
'
,
'
()
'
,
`auto closes @ (
${
lineNumber
}
,
${
column
}
)`
);
}
else
{
assertType
(
model
,
cursor
,
lineNumber
,
column
,
'
(
'
,
'
(
'
,
`does not auto close @ (
${
lineNumber
}
,
${
column
}
)`
);
}
}
}
});
mode
.
dispose
();
});
test
(
'
auto-pairing can be disabled
'
,
()
=>
{
let
mode
=
new
AutoClosingMode
();
usingCursor
({
text
:
[
'
var a = [];
'
,
'
var b = `asd`;
'
,
'
var c =
\'
asd
\'
;
'
,
'
var d = "asd";
'
,
'
var e = /*3*/ 3;
'
,
'
var f = /** 3 */3;
'
,
'
var g = (3+5);
'
,
'
var h = { a:
\'
value
\'
};
'
,
],
languageIdentifier
:
mode
.
getLanguageIdentifier
(),
editorOpts
:
{
autoClosingBrackets
:
{
enabledBefore
:
'
abc
'
,
autoClose
:
false
,
autoWrap
:
true
},
autoClosingQuotes
:
{
enabledBefore
:
'
abc
'
,
autoClose
:
false
,
autoWrap
:
true
}
}
},
(
model
,
cursor
)
=>
{
let
autoClosePositions
=
[
'
var a = [];
'
,
'
var b = `asd`;
'
,
'
var c =
\'
asd
\'
;
'
,
'
var d = "asd";
'
,
'
var e = /*3*/ 3;
'
,
'
var f = /** 3 */3;
'
,
'
var g = (3+5);
'
,
'
var h = { a:
\'
value
\'
};
'
,
];
for
(
let
i
=
0
,
len
=
autoClosePositions
.
length
;
i
<
len
;
i
++
)
{
const
lineNumber
=
i
+
1
;
const
autoCloseColumns
=
extractSpecialColumns
(
model
.
getLineMaxColumn
(
lineNumber
),
autoClosePositions
[
i
]);
for
(
let
column
=
1
;
column
<
autoCloseColumns
.
length
;
column
++
)
{
model
.
forceTokenization
(
lineNumber
);
if
(
autoCloseColumns
[
column
]
===
ColumnType
.
Special1
)
{
assertType
(
model
,
cursor
,
lineNumber
,
column
,
'
(
'
,
'
()
'
,
`auto closes @ (
${
lineNumber
}
,
${
column
}
)`
);
assertType
(
model
,
cursor
,
lineNumber
,
column
,
'
"
'
,
'
""
'
,
`auto closes @ (
${
lineNumber
}
,
${
column
}
)`
);
}
else
{
assertType
(
model
,
cursor
,
lineNumber
,
column
,
'
(
'
,
'
(
'
,
`does not auto close @ (
${
lineNumber
}
,
${
column
}
)`
);
assertType
(
model
,
cursor
,
lineNumber
,
column
,
'
"
'
,
'
"
'
,
`does not auto close @ (
${
lineNumber
}
,
${
column
}
)`
);
}
}
}
});
mode
.
dispose
();
});
test
(
'
auto wrapping is configurable
'
,
()
=>
{
let
mode
=
new
AutoClosingMode
();
usingCursor
({
text
:
[
'
var a = asd
'
],
languageIdentifier
:
mode
.
getLanguageIdentifier
()
},
(
model
,
cursor
)
=>
{
cursor
.
setSelections
(
'
test
'
,
[
new
Selection
(
1
,
1
,
1
,
4
),
new
Selection
(
1
,
9
,
1
,
12
),
]);
// type a `
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
`
'
},
'
keyboard
'
);
assert
.
equal
(
model
.
getValue
(),
'
`var` a = `asd`
'
);
});
usingCursor
({
text
:
[
'
var a = asd
'
],
languageIdentifier
:
mode
.
getLanguageIdentifier
(),
editorOpts
:
{
autoClosingBrackets
:
{
autoWrap
:
false
,
autoClose
:
true
,
enabledBefore
:
''
}
}
},
(
model
,
cursor
)
=>
{
cursor
.
setSelections
(
'
test
'
,
[
new
Selection
(
1
,
1
,
1
,
4
),
]);
// type a `
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
`
'
},
'
keyboard
'
);
assert
.
equal
(
model
.
getValue
(),
'
` a = asd
'
);
});
mode
.
dispose
();
});
test
(
'
quote
'
,
()
=>
{
let
mode
=
new
AutoClosingMode
();
usingCursor
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录