Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8e01f961
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,发现更多精彩内容 >>
提交
8e01f961
编写于
8月 17, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove SuggestModel#accept|onDidAccept
上级
1a5e5e43
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
35 deletion
+17
-35
src/vs/editor/contrib/suggest/browser/suggest.ts
src/vs/editor/contrib/suggest/browser/suggest.ts
+10
-8
src/vs/editor/contrib/suggest/common/suggestModel.ts
src/vs/editor/contrib/suggest/common/suggestModel.ts
+7
-27
未找到文件。
src/vs/editor/contrib/suggest/browser/suggest.ts
浏览文件 @
8e01f961
...
...
@@ -16,7 +16,7 @@ import { editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEdit
import
{
ISuggestSupport
,
SuggestRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
getSnippetController
}
from
'
vs/editor/contrib/snippet/common/snippet
'
;
import
{
getSnippetController
,
CodeSnippet
}
from
'
vs/editor/contrib/snippet/common/snippet
'
;
import
{
Context
as
SuggestContext
}
from
'
vs/editor/contrib/suggest/common/suggest
'
;
import
{
SuggestModel
}
from
'
../common/suggestModel
'
;
import
{
CompletionItem
}
from
'
../common/completionModel
'
;
...
...
@@ -54,8 +54,6 @@ export class SuggestController implements IEditorContribution {
this
.
toDispose
.
push
(
editor
.
onDidChangeModelMode
(()
=>
this
.
update
()));
this
.
toDispose
.
push
(
SuggestRegistry
.
onDidChange
(
this
.
update
,
this
));
this
.
toDispose
.
push
(
this
.
model
.
onDidAccept
(
e
=>
getSnippetController
(
this
.
editor
).
run
(
e
.
snippet
,
e
.
overwriteBefore
,
e
.
overwriteAfter
)));
this
.
update
();
}
...
...
@@ -78,12 +76,16 @@ export class SuggestController implements IEditorContribution {
}
private
onDidSelectItem
(
item
:
CompletionItem
):
void
{
if
(
!
item
)
{
this
.
model
.
cancel
();
return
;
if
(
item
)
{
const
{
insertText
,
overwriteBefore
,
overwriteAfter
}
=
item
.
suggestion
;
const
columnDelta
=
this
.
editor
.
getPosition
().
column
-
this
.
model
.
getTriggerPosition
().
column
;
getSnippetController
(
this
.
editor
).
run
(
new
CodeSnippet
(
insertText
),
overwriteBefore
+
columnDelta
,
overwriteAfter
);
}
const
{
overwriteBefore
,
overwriteAfter
}
=
item
.
suggestion
;
this
.
model
.
accept
(
item
.
suggestion
,
overwriteBefore
,
overwriteAfter
);
this
.
model
.
cancel
(
);
}
private
update
():
void
{
...
...
src/vs/editor/contrib/suggest/common/suggestModel.ts
浏览文件 @
8e01f961
...
...
@@ -10,8 +10,7 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICommonCodeEditor
,
ICursorSelectionChangedEvent
,
CursorChangeReason
,
IModel
,
IPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ISuggestSupport
,
ISuggestion
,
SuggestRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
CodeSnippet
}
from
'
vs/editor/contrib/snippet/common/snippet
'
;
import
{
ISuggestSupport
,
SuggestRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
ISuggestionItem
,
provideSuggestionItems
}
from
'
./suggest
'
;
import
{
CompletionModel
}
from
'
./completionModel
'
;
...
...
@@ -29,12 +28,6 @@ export interface ISuggestEvent {
auto
:
boolean
;
}
export
interface
IAcceptEvent
{
snippet
:
CodeSnippet
;
overwriteBefore
:
number
;
overwriteAfter
:
number
;
}
class
Context
{
lineNumber
:
number
;
...
...
@@ -169,9 +162,6 @@ export class SuggestModel implements IDisposable {
private
_onDidSuggest
:
Emitter
<
ISuggestEvent
>
=
new
Emitter
();
get
onDidSuggest
():
Event
<
ISuggestEvent
>
{
return
this
.
_onDidSuggest
.
event
;
}
private
_onDidAccept
:
Emitter
<
IAcceptEvent
>
=
new
Emitter
();
get
onDidAccept
():
Event
<
IAcceptEvent
>
{
return
this
.
_onDidAccept
.
event
;
}
constructor
(
private
editor
:
ICommonCodeEditor
)
{
this
.
state
=
State
.
Idle
;
this
.
triggerAutoSuggestPromise
=
null
;
...
...
@@ -182,7 +172,7 @@ export class SuggestModel implements IDisposable {
this
.
context
=
null
;
this
.
toDispose
=
[];
this
.
toDispose
.
push
(
this
.
_onDid
Accept
,
this
.
_onDid
Cancel
,
this
.
_onDidSuggest
,
this
.
_onDidTrigger
);
this
.
toDispose
.
push
(
this
.
_onDidCancel
,
this
.
_onDidSuggest
,
this
.
_onDidTrigger
);
this
.
toDispose
.
push
(
this
.
editor
.
onDidChangeConfiguration
(()
=>
this
.
onEditorConfigurationChange
()));
this
.
toDispose
.
push
(
this
.
editor
.
onDidChangeCursorSelection
(
e
=>
this
.
onCursorChange
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
onDidChangeModel
(()
=>
this
.
cancel
()));
...
...
@@ -321,6 +311,11 @@ export class SuggestModel implements IDisposable {
}).
then
(
null
,
onUnexpectedError
);
}
public
getTriggerPosition
():
IPosition
{
const
{
lineNumber
,
column
}
=
this
.
context
;
return
{
lineNumber
,
column
};
}
private
onNewContext
(
ctx
:
Context
):
void
{
if
(
this
.
context
&&
this
.
context
.
isDifferentContext
(
ctx
))
{
if
(
this
.
context
.
shouldRetrigger
(
ctx
))
{
...
...
@@ -361,21 +356,6 @@ export class SuggestModel implements IDisposable {
}
}
accept
(
suggestion
:
ISuggestion
,
overwriteBefore
:
number
,
overwriteAfter
:
number
):
boolean
{
if
(
this
.
suggestionItems
===
null
)
{
return
false
;
}
this
.
_onDidAccept
.
fire
({
snippet
:
new
CodeSnippet
(
suggestion
.
insertText
),
overwriteBefore
:
overwriteBefore
+
(
this
.
editor
.
getPosition
().
column
-
this
.
context
.
column
),
overwriteAfter
});
this
.
cancel
();
return
true
;
}
private
onEditorConfigurationChange
():
void
{
this
.
autoSuggestDelay
=
this
.
editor
.
getConfiguration
().
contribInfo
.
quickSuggestionsDelay
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录