Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
700686a7
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,发现更多精彩内容 >>
提交
700686a7
编写于
10月 24, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #61296: Ensure getWordAtPosition returns a word that touches the original passed in position
上级
de63859b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
2 deletion
+55
-2
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+4
-2
src/vs/editor/test/common/model/model.test.ts
src/vs/editor/test/common/model/model.test.ts
+26
-0
src/vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts
...ts/snippets/test/electron-browser/snippetsService.test.ts
+25
-0
未找到文件。
src/vs/editor/common/model/textModel.ts
浏览文件 @
700686a7
...
...
@@ -2004,7 +2004,8 @@ export class TextModel extends Disposable implements model.ITextModel {
lineContent
.
substring
(
rbStartOffset
,
rbEndOffset
),
rbStartOffset
);
if
(
rightBiasedWord
)
{
// Make sure the result touches the original passed in position
if
(
rightBiasedWord
&&
rightBiasedWord
.
startColumn
<=
_position
.
column
&&
_position
.
column
<=
rightBiasedWord
.
endColumn
)
{
return
rightBiasedWord
;
}
...
...
@@ -2018,7 +2019,8 @@ export class TextModel extends Disposable implements model.ITextModel {
lineContent
.
substring
(
lbStartOffset
,
lbEndOffset
),
lbStartOffset
);
if
(
leftBiasedWord
)
{
// Make sure the result touches the original passed in position
if
(
leftBiasedWord
&&
leftBiasedWord
.
startColumn
<=
_position
.
column
&&
_position
.
column
<=
leftBiasedWord
.
endColumn
)
{
return
leftBiasedWord
;
}
}
...
...
src/vs/editor/test/common/model/model.test.ts
浏览文件 @
700686a7
...
...
@@ -462,4 +462,30 @@ suite('Editor Model - Words', () => {
assert
.
deepEqual
(
model
.
getWordAtPosition
(
new
Position
(
1
,
6
)),
{
word
:
'
xx
'
,
startColumn
:
4
,
endColumn
:
6
});
assert
.
deepEqual
(
model
.
getWordAtPosition
(
new
Position
(
1
,
7
)),
{
word
:
'
ab
'
,
startColumn
:
7
,
endColumn
:
9
});
});
test
(
'
issue #61296: VS code freezes when editing CSS file with emoji
'
,
()
=>
{
const
MODE_ID
=
new
LanguageIdentifier
(
'
testMode
'
,
4
);
const
mode
=
new
class
extends
MockMode
{
constructor
()
{
super
(
MODE_ID
);
this
.
_register
(
LanguageConfigurationRegistry
.
register
(
this
.
getLanguageIdentifier
(),
{
wordPattern
:
/
(
#
?
-
?\d
*
\.\d\w
*%
?)
|
(
::
?[\w
-
]
*
(?=[^
,{;
]
*
[
,{
]))
|
(([
@#.!
])?[\w
-?
]
+%
?
|
[
@#!.
])
/g
}));
}
};
disposables
.
push
(
mode
);
const
thisModel
=
TextModel
.
createFromString
(
'
.🐷-a-b
'
,
undefined
,
MODE_ID
);
disposables
.
push
(
thisModel
);
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
1
)),
{
word
:
'
.
'
,
startColumn
:
1
,
endColumn
:
2
});
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
2
)),
{
word
:
'
.
'
,
startColumn
:
1
,
endColumn
:
2
});
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
3
)),
null
);
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
4
)),
{
word
:
'
-a-b
'
,
startColumn
:
4
,
endColumn
:
8
});
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
5
)),
{
word
:
'
-a-b
'
,
startColumn
:
4
,
endColumn
:
8
});
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
6
)),
{
word
:
'
-a-b
'
,
startColumn
:
4
,
endColumn
:
8
});
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
7
)),
{
word
:
'
-a-b
'
,
startColumn
:
4
,
endColumn
:
8
});
assert
.
deepEqual
(
thisModel
.
getWordAtPosition
(
new
Position
(
1
,
8
)),
{
word
:
'
-a-b
'
,
startColumn
:
4
,
endColumn
:
8
});
});
});
src/vs/workbench/parts/snippets/test/electron-browser/snippetsService.test.ts
浏览文件 @
700686a7
...
...
@@ -11,6 +11,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
ISnippetsService
}
from
'
vs/workbench/parts/snippets/electron-browser/snippets.contribution
'
;
import
{
Snippet
,
SnippetSource
}
from
'
vs/workbench/parts/snippets/electron-browser/snippetsFile
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
class
SimpleSnippetService
implements
ISnippetsService
{
_serviceBrand
:
any
;
...
...
@@ -327,4 +328,28 @@ suite('SnippetsService', function () {
assert
.
equal
(
result
.
suggestions
.
length
,
1
);
});
test
(
'
issue #61296: VS code freezes when editing CSS file with emoji
'
,
async
function
()
{
let
toDispose
=
LanguageConfigurationRegistry
.
register
(
modeService
.
getLanguageIdentifier
(
'
fooLang
'
),
{
wordPattern
:
/
(
#
?
-
?\d
*
\.\d\w
*%
?)
|
(
::
?[\w
-
]
*
(?=[^
,{;
]
*
[
,{
]))
|
(([
@#.!
])?[\w
-?
]
+%
?
|
[
@#!.
])
/g
});
snippetService
=
new
SimpleSnippetService
([
new
Snippet
(
[
'
fooLang
'
],
'
bug
'
,
'
-a-bug
'
,
''
,
'
second
'
,
''
,
SnippetSource
.
User
)]);
const
provider
=
new
SnippetCompletionProvider
(
modeService
,
snippetService
);
let
model
=
TextModel
.
createFromString
(
'
.🐷-a-b
'
,
undefined
,
modeService
.
getLanguageIdentifier
(
'
fooLang
'
));
let
result
=
await
provider
.
provideCompletionItems
(
model
,
new
Position
(
1
,
8
));
assert
.
equal
(
result
.
suggestions
.
length
,
1
);
toDispose
.
dispose
();
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录