Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
旅途_2012
vscode
提交
556bfbee
V
vscode
项目概览
旅途_2012
/
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,发现更多精彩内容 >>
提交
556bfbee
编写于
3月 06, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #43270
上级
bf54e67a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
15 deletion
+54
-15
src/vs/editor/contrib/snippet/snippetController2.ts
src/vs/editor/contrib/snippet/snippetController2.ts
+19
-2
src/vs/editor/contrib/snippet/snippetSession.ts
src/vs/editor/contrib/snippet/snippetSession.ts
+6
-4
src/vs/editor/contrib/snippet/test/snippetController2.test.ts
...vs/editor/contrib/snippet/test/snippetController2.test.ts
+28
-8
src/vs/editor/contrib/snippet/test/snippetSession.test.ts
src/vs/editor/contrib/snippet/test/snippetSession.test.ts
+1
-1
未找到文件。
src/vs/editor/contrib/snippet/snippetController2.ts
浏览文件 @
556bfbee
...
...
@@ -19,6 +19,7 @@ import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from '
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
SnippetSession
}
from
'
./snippetSession
'
;
import
{
EditorState
,
CodeEditorStateFlag
}
from
'
vs/editor/browser/core/editorState
'
;
export
class
SnippetController2
implements
IEditorContribution
{
...
...
@@ -113,10 +114,26 @@ export class SnippetController2 implements IEditorContribution {
this
.
_updateState
();
// we listen on model and selection changes. usually
// both events come in together and this is to prevent
// that we don't call _updateState twice.
let
state
:
EditorState
;
let
dedupedUpdateState
=
()
=>
{
if
(
!
state
||
!
state
.
validate
(
this
.
_editor
))
{
this
.
_updateState
();
state
=
new
EditorState
(
this
.
_editor
,
CodeEditorStateFlag
.
Selection
|
CodeEditorStateFlag
.
Value
);
}
};
this
.
_snippetListener
=
[
this
.
_editor
.
onDidChangeModelContent
(
e
=>
e
.
isFlush
&&
this
.
cancel
()),
this
.
_editor
.
onDidChangeModelContent
(
e
=>
{
if
(
e
.
isFlush
)
{
this
.
cancel
();
}
else
{
setTimeout
(
dedupedUpdateState
,
0
);
}
}),
this
.
_editor
.
onDidChangeCursorSelection
(
dedupedUpdateState
),
this
.
_editor
.
onDidChangeModel
(()
=>
this
.
cancel
()),
this
.
_editor
.
onDidChangeCursorSelection
(()
=>
this
.
_updateState
())
];
}
...
...
src/vs/editor/contrib/snippet/snippetSession.ts
浏览文件 @
556bfbee
...
...
@@ -197,10 +197,6 @@ export class OneSnippet {
let
ranges
:
Range
[]
|
undefined
;
for
(
const
placeholder
of
placeholdersWithEqualIndex
)
{
if
(
placeholder
.
isFinalTabstop
)
{
// ignore those
break
;
}
if
(
!
ranges
)
{
ranges
=
[];
...
...
@@ -574,6 +570,12 @@ export class SnippetSession {
return
false
;
}
if
(
allPossibleSelections
.
has
(
0
))
{
// selection overlaps with a final tab stop which means
// we done
return
false
;
}
// add selections from 'this' snippet so that we know all
// selections for this placeholder
allPossibleSelections
.
forEach
((
array
,
index
)
=>
{
...
...
src/vs/editor/contrib/snippet/test/snippetController2.test.ts
浏览文件 @
556bfbee
...
...
@@ -11,6 +11,7 @@ import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKe
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
Handler
}
from
'
vs/editor/common/editorCommon
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
suite
(
'
SnippetController2
'
,
function
()
{
...
...
@@ -133,11 +134,11 @@ suite('SnippetController2', function () {
assertSelections
(
editor
,
new
Selection
(
1
,
1
,
1
,
7
),
new
Selection
(
2
,
5
,
2
,
11
));
editor
.
trigger
(
'
test
'
,
'
cut
'
,
{});
assertContextKeys
(
contextKeys
,
true
,
false
,
tru
e
);
assertContextKeys
(
contextKeys
,
false
,
false
,
fals
e
);
assertSelections
(
editor
,
new
Selection
(
1
,
1
,
1
,
1
),
new
Selection
(
2
,
5
,
2
,
5
));
editor
.
trigger
(
'
test
'
,
'
type
'
,
{
text
:
'
abc
'
});
assertContextKeys
(
contextKeys
,
true
,
false
,
tru
e
);
assertContextKeys
(
contextKeys
,
false
,
false
,
fals
e
);
ctrl
.
next
();
assertContextKeys
(
contextKeys
,
false
,
false
,
false
);
...
...
@@ -159,9 +160,9 @@ suite('SnippetController2', function () {
assertSelections
(
editor
,
new
Selection
(
1
,
4
,
1
,
4
),
new
Selection
(
2
,
8
,
2
,
8
));
assertContextKeys
(
contextKeys
,
true
,
false
,
true
);
ctrl
.
next
();
assertSelections
(
editor
,
new
Selection
(
1
,
7
,
1
,
7
),
new
Selection
(
2
,
11
,
2
,
11
));
assertContextKeys
(
contextKeys
,
true
,
true
,
true
);
//
ctrl.next();
//
assertSelections(editor, new Selection(1, 7, 1, 7), new Selection(2, 11, 2, 11));
//
assertContextKeys(contextKeys, true, true, true);
ctrl
.
next
();
assertSelections
(
editor
,
new
Selection
(
1
,
7
,
1
,
7
),
new
Selection
(
2
,
11
,
2
,
11
));
...
...
@@ -176,10 +177,10 @@ suite('SnippetController2', function () {
ctrl
.
insert
(
'
farboo
'
);
assertSelections
(
editor
,
new
Selection
(
1
,
7
,
1
,
7
),
new
Selection
(
2
,
11
,
2
,
11
));
assertContextKeys
(
contextKeys
,
true
,
false
,
true
);
//
assertContextKeys(contextKeys, true, false, true);
ctrl
.
next
();
assertSelections
(
editor
,
new
Selection
(
1
,
7
,
1
,
7
),
new
Selection
(
2
,
11
,
2
,
11
));
//
ctrl.next();
//
assertSelections(editor, new Selection(1, 7, 1, 7), new Selection(2, 11, 2, 11));
assertContextKeys
(
contextKeys
,
false
,
false
,
false
);
});
...
...
@@ -401,4 +402,23 @@ suite('SnippetController2', function () {
assertContextKeys
(
contextKeys
,
false
,
false
,
false
);
assertSelections
(
editor
,
new
Selection
(
1
,
22
,
1
,
22
));
});
test
(
'
A little confusing visual effect of highlighting for snippet tabstop #43270
'
,
async
function
()
{
const
ctrl
=
new
SnippetController2
(
editor
,
logService
,
contextKeys
);
model
.
setValue
(
''
);
editor
.
setSelection
(
new
Selection
(
1
,
1
,
1
,
1
));
ctrl
.
insert
(
'
background-color: ${1:fff};$0
'
);
assertSelections
(
editor
,
new
Selection
(
1
,
19
,
1
,
22
));
editor
.
setSelection
(
new
Selection
(
1
,
22
,
1
,
22
));
assertContextKeys
(
contextKeys
,
true
,
false
,
true
);
editor
.
trigger
(
''
,
'
deleteRight
'
,
null
);
assert
.
equal
(
model
.
getValue
(),
'
background-color: fff
'
);
await
timeout
(
0
);
// this depends on re-scheduling of events...
assertContextKeys
(
contextKeys
,
false
,
false
,
false
);
});
});
src/vs/editor/contrib/snippet/test/snippetSession.test.ts
浏览文件 @
556bfbee
...
...
@@ -331,7 +331,7 @@ suite('SnippetSession', function () {
// reset selection to placeholder
session
.
next
();
assert
.
equal
(
session
.
isSelectionWithinPlaceholders
(),
tru
e
);
assert
.
equal
(
session
.
isSelectionWithinPlaceholders
(),
fals
e
);
assert
.
equal
(
session
.
isAtLastPlaceholder
,
true
);
assertSelections
(
editor
,
new
Selection
(
1
,
13
,
1
,
13
),
new
Selection
(
2
,
17
,
2
,
17
));
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录