Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ecd87082
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,发现更多精彩内容 >>
提交
ecd87082
编写于
5月 22, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "resolve completion item before inserting (except when using commit characters), #73311"
This reverts commit
b513141f
.
上级
7b70767c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
27 deletion
+14
-27
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+6
-22
src/vs/editor/contrib/suggest/suggestWidget.ts
src/vs/editor/contrib/suggest/suggestWidget.ts
+5
-2
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
+3
-3
未找到文件。
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
ecd87082
...
...
@@ -33,7 +33,6 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerServ
import
{
IdleValue
}
from
'
vs/base/common/async
'
;
import
{
isObject
}
from
'
vs/base/common/types
'
;
import
{
CommitCharacterController
}
from
'
./suggestCommitCharacters
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
export
class
SuggestController
implements
IEditorContribution
{
...
...
@@ -65,14 +64,10 @@ export class SuggestController implements IEditorContribution {
const
widget
=
this
.
_instantiationService
.
createInstance
(
SuggestWidget
,
this
.
_editor
);
this
.
_toDispose
.
push
(
widget
);
this
.
_toDispose
.
push
(
widget
.
onDidSelect
(
item
=>
this
.
_
insertSuggestion
(
item
,
false
,
true
),
this
));
this
.
_toDispose
.
push
(
widget
.
onDidSelect
(
item
=>
this
.
_
onDidSelectItem
(
item
,
false
,
true
),
this
));
// Wire up logic to accept a suggestion on certain characters
const
commitCharacterController
=
new
CommitCharacterController
(
this
.
_editor
,
widget
,
item
=>
this
.
_insertSuggestion
(
item
,
false
,
true
,
true
)
);
const
commitCharacterController
=
new
CommitCharacterController
(
this
.
_editor
,
widget
,
item
=>
this
.
_onDidSelectItem
(
item
,
false
,
true
));
this
.
_toDispose
.
push
(
commitCharacterController
,
this
.
_model
.
onDidSuggest
(
e
=>
{
...
...
@@ -166,23 +161,12 @@ export class SuggestController implements IEditorContribution {
}
}
protected
_insertSuggestion
(
event
:
ISelectedSuggestion
|
undefined
,
keepAlternativeSuggestions
:
boolean
,
undoStops
:
boolean
):
Promise
<
void
>
;
protected
_insertSuggestion
(
event
:
ISelectedSuggestion
|
undefined
,
keepAlternativeSuggestions
:
boolean
,
undoStops
:
boolean
,
noResolve
:
true
):
void
;
protected
async
_insertSuggestion
(
event
:
ISelectedSuggestion
|
undefined
,
keepAlternativeSuggestions
:
boolean
,
undoStops
:
boolean
,
noResolve
?:
true
):
Promise
<
void
>
{
protected
_onDidSelectItem
(
event
:
ISelectedSuggestion
|
undefined
,
keepAlternativeSuggestions
:
boolean
,
undoStops
:
boolean
):
void
{
if
(
!
event
||
!
event
.
item
)
{
this
.
_alternatives
.
getValue
().
reset
();
this
.
_model
.
cancel
();
return
;
}
if
(
!
noResolve
)
{
// DEFAULT is to wait for the item to be resolve
// but the current implementation of commit characters
// doesn't allow to wait and that's why there is a
// sync (no resolve) case
await
event
.
item
.
resolve
(
CancellationToken
.
None
);
}
if
(
!
this
.
_editor
.
hasModel
())
{
return
;
}
...
...
@@ -249,7 +233,7 @@ export class SuggestController implements IEditorContribution {
if
(
modelVersionNow
!==
model
.
getAlternativeVersionId
())
{
model
.
undo
();
}
this
.
_
insertSuggestion
(
next
,
false
,
false
);
this
.
_
onDidSelectItem
(
next
,
false
,
false
);
break
;
}
});
...
...
@@ -331,7 +315,7 @@ export class SuggestController implements IEditorContribution {
return
;
}
this
.
_editor
.
pushUndoStop
();
this
.
_
insertSuggestion
({
index
,
item
,
model
:
completionModel
},
true
,
false
);
this
.
_
onDidSelectItem
({
index
,
item
,
model
:
completionModel
},
true
,
false
);
},
undefined
,
listener
);
});
...
...
@@ -343,7 +327,7 @@ export class SuggestController implements IEditorContribution {
acceptSelectedSuggestion
(
keepAlternativeSuggestions
?:
boolean
):
void
{
const
item
=
this
.
_widget
.
getValue
().
getFocusedItem
();
this
.
_
insertSuggestion
(
item
,
!!
keepAlternativeSuggestions
,
true
);
this
.
_
onDidSelectItem
(
item
,
!!
keepAlternativeSuggestions
,
true
);
}
acceptNextSuggestion
()
{
...
...
src/vs/editor/contrib/suggest/suggestWidget.ts
浏览文件 @
ecd87082
...
...
@@ -30,6 +30,7 @@ import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer';
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
TimeoutTimer
,
CancelablePromise
,
createCancelablePromise
}
from
'
vs/base/common/async
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
CompletionItemKind
,
completionKindToCssClass
}
from
'
vs/editor/common/modes
'
;
import
{
IconLabel
,
IIconLabelValueOptions
}
from
'
vs/base/browser/ui/iconLabel/iconLabel
'
;
import
{
getIconClasses
}
from
'
vs/editor/common/services/getIconClasses
'
;
...
...
@@ -544,8 +545,10 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
return
;
}
this
.
onDidSelectEmitter
.
fire
({
item
,
index
,
model
:
completionModel
});
this
.
editor
.
focus
();
item
.
resolve
(
CancellationToken
.
None
).
then
(()
=>
{
this
.
onDidSelectEmitter
.
fire
({
item
,
index
,
model
:
completionModel
});
this
.
editor
.
focus
();
});
}
private
_getSuggestionAriaAlertLabel
(
item
:
CompletionItem
):
string
{
...
...
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
浏览文件 @
ecd87082
...
...
@@ -671,8 +671,8 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
return
withOracle
(
async
(
sugget
,
editor
)
=>
{
class
TestCtrl
extends
SuggestController
{
_
insertSuggestion
(
item
:
ISelectedSuggestion
)
{
return
super
.
_insertSuggestion
(
item
,
false
,
true
);
_
onDidSelectItem
(
item
:
ISelectedSuggestion
)
{
super
.
_onDidSelectItem
(
item
,
false
,
true
);
}
}
const
ctrl
=
<
TestCtrl
>
editor
.
registerAndInstantiateContribution
(
TestCtrl
);
...
...
@@ -687,7 +687,7 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
const
[
first
]
=
event
.
completionModel
.
items
;
assert
.
equal
(
first
.
completion
.
label
,
'
bar
'
);
return
ctrl
.
_insertSuggestion
({
item
:
first
,
index
:
0
,
model
:
event
.
completionModel
});
ctrl
.
_onDidSelectItem
({
item
:
first
,
index
:
0
,
model
:
event
.
completionModel
});
});
assert
.
equal
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录