Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
e07e2b01
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
e07e2b01
编写于
8月 31, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes Microsoft/monaco-editor#133: Brackets are case-insensitive
上级
daf411d8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
7 deletion
+46
-7
src/vs/editor/common/model/textModelWithTokens.ts
src/vs/editor/common/model/textModelWithTokens.ts
+9
-1
src/vs/editor/common/modes/supports/electricCharacter.ts
src/vs/editor/common/modes/supports/electricCharacter.ts
+2
-0
src/vs/editor/common/modes/supports/richEditBrackets.ts
src/vs/editor/common/modes/supports/richEditBrackets.ts
+4
-4
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
+2
-0
src/vs/editor/test/common/model/textModelWithTokens.test.ts
src/vs/editor/test/common/model/textModelWithTokens.test.ts
+29
-2
未找到文件。
src/vs/editor/common/model/textModelWithTokens.ts
浏览文件 @
e07e2b01
...
...
@@ -716,8 +716,10 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
return
result
;
}
public
findMatchingBracketUp
(
bracket
:
string
,
_position
:
editorCommon
.
IPosition
):
Range
{
public
findMatchingBracketUp
(
_bracket
:
string
,
_position
:
editorCommon
.
IPosition
):
Range
{
let
bracket
=
_bracket
.
toLowerCase
();
let
position
=
this
.
validatePosition
(
_position
);
let
modeTransitions
=
this
.
_lines
[
position
.
lineNumber
-
1
].
getModeTransitions
(
this
.
getModeId
());
let
currentModeIndex
=
ModeTransition
.
findIndexInSegmentsArray
(
modeTransitions
,
position
.
column
-
1
);
let
currentMode
=
modeTransitions
[
currentModeIndex
];
...
...
@@ -779,6 +781,8 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
// check that we didn't hit a bracket too far away from position
if
(
foundBracket
&&
foundBracket
.
startColumn
<=
position
.
column
&&
position
.
column
<=
foundBracket
.
endColumn
)
{
let
foundBracketText
=
lineText
.
substring
(
foundBracket
.
startColumn
-
1
,
foundBracket
.
endColumn
-
1
);
foundBracketText
=
foundBracketText
.
toLowerCase
();
let
r
=
this
.
_matchFoundBracket
(
foundBracket
,
prevModeBrackets
.
textIsBracket
[
foundBracketText
],
prevModeBrackets
.
textIsOpenBracket
[
foundBracketText
]);
// check that we can actually match this bracket
...
...
@@ -812,6 +816,8 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
// check that we didn't hit a bracket too far away from position
if
(
foundBracket
.
startColumn
<=
position
.
column
&&
position
.
column
<=
foundBracket
.
endColumn
)
{
let
foundBracketText
=
lineText
.
substring
(
foundBracket
.
startColumn
-
1
,
foundBracket
.
endColumn
-
1
);
foundBracketText
=
foundBracketText
.
toLowerCase
();
let
r
=
this
.
_matchFoundBracket
(
foundBracket
,
currentModeBrackets
.
textIsBracket
[
foundBracketText
],
currentModeBrackets
.
textIsOpenBracket
[
foundBracketText
]);
// check that we can actually match this bracket
...
...
@@ -889,6 +895,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
let
hitText
=
lineText
.
substring
(
r
.
startColumn
-
1
,
r
.
endColumn
-
1
);
hitText
=
hitText
.
toLowerCase
();
if
(
hitText
===
bracket
.
open
)
{
count
++
;
...
...
@@ -955,6 +962,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
}
let
hitText
=
lineText
.
substring
(
r
.
startColumn
-
1
,
r
.
endColumn
-
1
);
hitText
=
hitText
.
toLowerCase
();
if
(
hitText
===
bracket
.
open
)
{
count
++
;
...
...
src/vs/editor/common/modes/supports/electricCharacter.ts
浏览文件 @
e07e2b01
...
...
@@ -143,6 +143,8 @@ export class Brackets {
let
r
=
BracketsUtils
.
findPrevBracketInToken
(
reversedBracketRegex
,
1
,
lineText
,
tokenStart
,
tokenEnd
);
if
(
r
)
{
let
text
=
lineText
.
substring
(
r
.
startColumn
-
1
,
r
.
endColumn
-
1
);
text
=
text
.
toLowerCase
();
let
isOpen
=
this
.
_richEditBrackets
.
textIsOpenBracket
[
text
];
if
(
!
isOpen
)
{
return
{
...
...
src/vs/editor/common/modes/supports/richEditBrackets.ts
浏览文件 @
e07e2b01
...
...
@@ -40,10 +40,10 @@ export class RichEditBrackets implements IRichEditBrackets {
this
.
textIsOpenBracket
=
{};
this
.
maxBracketLength
=
0
;
this
.
brackets
.
forEach
((
b
)
=>
{
this
.
textIsBracket
[
b
.
open
]
=
b
;
this
.
textIsBracket
[
b
.
close
]
=
b
;
this
.
textIsOpenBracket
[
b
.
open
]
=
true
;
this
.
textIsOpenBracket
[
b
.
close
]
=
false
;
this
.
textIsBracket
[
b
.
open
.
toLowerCase
()
]
=
b
;
this
.
textIsBracket
[
b
.
close
.
toLowerCase
()
]
=
b
;
this
.
textIsOpenBracket
[
b
.
open
.
toLowerCase
()
]
=
true
;
this
.
textIsOpenBracket
[
b
.
close
.
toLowerCase
()
]
=
false
;
this
.
maxBracketLength
=
Math
.
max
(
this
.
maxBracketLength
,
b
.
open
.
length
);
this
.
maxBracketLength
=
Math
.
max
(
this
.
maxBracketLength
,
b
.
close
.
length
);
});
...
...
src/vs/editor/contrib/smartSelect/common/tokenTree.ts
浏览文件 @
e07e2b01
...
...
@@ -187,6 +187,8 @@ class TokenScanner {
let
bracketIsOpen
:
boolean
=
false
;
if
(
nextBracket
)
{
let
bracketText
=
this
.
_currentLineText
.
substring
(
nextBracket
.
startColumn
-
1
,
nextBracket
.
endColumn
-
1
);
bracketText
=
bracketText
.
toLowerCase
();
bracketData
=
this
.
_currentModeBrackets
.
textIsBracket
[
bracketText
];
bracketIsOpen
=
this
.
_currentModeBrackets
.
textIsOpenBracket
[
bracketText
];
}
...
...
src/vs/editor/test/common/model/textModelWithTokens.test.ts
浏览文件 @
e07e2b01
...
...
@@ -297,7 +297,34 @@ suite('TextModelWithTokens regression tests', () => {
model
.
dispose
();
});
// test('Microsoft/monaco-editor#133: Error: Cannot read property \'modeId\' of undefined', () => {
test
(
'
Microsoft/monaco-editor#133: Error: Cannot read property
\'
modeId
\'
of undefined
'
,
()
=>
{
class
BracketMode
extends
MockMode
{
constructor
()
{
super
();
LanguageConfigurationRegistry
.
register
(
this
.
getId
(),
{
brackets
:
[
[
'
module
'
,
'
end module
'
],
[
'
sub
'
,
'
end sub
'
]
]
});
}
}
// });
let
model
=
Model
.
createFromString
([
'
Imports System
'
,
'
Imports System.Collections.Generic
'
,
''
,
'
Module m1
'
,
''
,
'
\t
Sub Main()
'
,
'
\t
End Sub
'
,
''
,
'
End Module
'
,
].
join
(
'
\n
'
),
undefined
,
new
BracketMode
());
let
actual
=
model
.
matchBracket
(
new
Position
(
4
,
1
));
assert
.
deepEqual
(
actual
,
[
new
Range
(
4
,
1
,
4
,
7
),
new
Range
(
9
,
1
,
9
,
11
)]);
model
.
dispose
();
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录