Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
df08d729
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,发现更多精彩内容 >>
提交
df08d729
编写于
5月 21, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move commit character logic to its own file, #73311
上级
a27a6885
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
53 deletion
+63
-53
src/vs/editor/contrib/suggest/suggestCommitCharacters.ts
src/vs/editor/contrib/suggest/suggestCommitCharacters.ts
+59
-0
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+4
-53
未找到文件。
src/vs/editor/contrib/suggest/suggestCommitCharacters.ts
0 → 100644
浏览文件 @
df08d729
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
isNonEmptyArray
}
from
'
vs/base/common/arrays
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ISelectedSuggestion
,
SuggestWidget
}
from
'
./suggestWidget
'
;
import
{
CharacterSet
}
from
'
vs/editor/common/core/characterClassifier
'
;
export
class
CommitCharacterController
{
private
_disposables
:
IDisposable
[]
=
[];
private
_active
?:
{
readonly
acceptCharacters
:
CharacterSet
;
readonly
item
:
ISelectedSuggestion
;
};
constructor
(
editor
:
ICodeEditor
,
widget
:
SuggestWidget
,
accept
:
(
selected
:
ISelectedSuggestion
)
=>
any
)
{
this
.
_disposables
.
push
(
widget
.
onDidShow
(()
=>
this
.
_onItem
(
widget
.
getFocusedItem
())));
this
.
_disposables
.
push
(
widget
.
onDidFocus
(
this
.
_onItem
,
this
));
this
.
_disposables
.
push
(
widget
.
onDidHide
(
this
.
reset
,
this
));
this
.
_disposables
.
push
(
editor
.
onWillType
(
text
=>
{
if
(
this
.
_active
)
{
const
ch
=
text
.
charCodeAt
(
text
.
length
-
1
);
if
(
this
.
_active
.
acceptCharacters
.
has
(
ch
)
&&
editor
.
getConfiguration
().
contribInfo
.
acceptSuggestionOnCommitCharacter
)
{
accept
(
this
.
_active
.
item
);
}
}
}));
}
private
_onItem
(
selected
:
ISelectedSuggestion
|
undefined
):
void
{
if
(
!
selected
||
!
isNonEmptyArray
(
selected
.
item
.
completion
.
commitCharacters
))
{
this
.
reset
();
return
;
}
const
acceptCharacters
=
new
CharacterSet
();
for
(
const
ch
of
selected
.
item
.
completion
.
commitCharacters
)
{
if
(
ch
.
length
>
0
)
{
acceptCharacters
.
add
(
ch
.
charCodeAt
(
0
));
}
}
this
.
_active
=
{
acceptCharacters
,
item
:
selected
};
}
reset
():
void
{
this
.
_active
=
undefined
;
}
dispose
()
{
dispose
(
this
.
_disposables
);
}
}
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
df08d729
...
...
@@ -31,57 +31,8 @@ import { WordContextKey } from 'vs/editor/contrib/suggest/wordContextKey';
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IdleValue
}
from
'
vs/base/common/async
'
;
import
{
CharacterSet
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
isObject
}
from
'
vs/base/common/types
'
;
class
AcceptOnCharacterOracle
{
private
_disposables
:
IDisposable
[]
=
[];
private
_active
?:
{
readonly
acceptCharacters
:
CharacterSet
;
readonly
item
:
ISelectedSuggestion
;
};
constructor
(
editor
:
ICodeEditor
,
widget
:
SuggestWidget
,
accept
:
(
selected
:
ISelectedSuggestion
)
=>
any
)
{
this
.
_disposables
.
push
(
widget
.
onDidShow
(()
=>
this
.
_onItem
(
widget
.
getFocusedItem
())));
this
.
_disposables
.
push
(
widget
.
onDidFocus
(
this
.
_onItem
,
this
));
this
.
_disposables
.
push
(
widget
.
onDidHide
(
this
.
reset
,
this
));
this
.
_disposables
.
push
(
editor
.
onWillType
(
text
=>
{
if
(
this
.
_active
)
{
const
ch
=
text
.
charCodeAt
(
text
.
length
-
1
);
if
(
this
.
_active
.
acceptCharacters
.
has
(
ch
)
&&
editor
.
getConfiguration
().
contribInfo
.
acceptSuggestionOnCommitCharacter
)
{
accept
(
this
.
_active
.
item
);
}
}
}));
}
private
_onItem
(
selected
:
ISelectedSuggestion
|
undefined
):
void
{
if
(
!
selected
||
!
isNonEmptyArray
(
selected
.
item
.
completion
.
commitCharacters
))
{
this
.
reset
();
return
;
}
const
acceptCharacters
=
new
CharacterSet
();
for
(
const
ch
of
selected
.
item
.
completion
.
commitCharacters
)
{
if
(
ch
.
length
>
0
)
{
acceptCharacters
.
add
(
ch
.
charCodeAt
(
0
));
}
}
this
.
_active
=
{
acceptCharacters
,
item
:
selected
};
}
reset
():
void
{
this
.
_active
=
undefined
;
}
dispose
()
{
dispose
(
this
.
_disposables
);
}
}
import
{
CommitCharacterController
}
from
'
./suggestCommitCharacters
'
;
export
class
SuggestController
implements
IEditorContribution
{
...
...
@@ -116,12 +67,12 @@ export class SuggestController implements IEditorContribution {
this
.
_toDispose
.
push
(
widget
.
onDidSelect
(
item
=>
this
.
_onDidSelectItem
(
item
,
false
,
true
),
this
));
// Wire up logic to accept a suggestion on certain characters
const
autoAcceptOracle
=
new
AcceptOnCharacterOracle
(
this
.
_editor
,
widget
,
item
=>
this
.
_onDidSelectItem
(
item
,
false
,
true
));
const
commitCharacterController
=
new
CommitCharacterController
(
this
.
_editor
,
widget
,
item
=>
this
.
_onDidSelectItem
(
item
,
false
,
true
));
this
.
_toDispose
.
push
(
autoAcceptOracle
,
commitCharacterController
,
this
.
_model
.
onDidSuggest
(
e
=>
{
if
(
e
.
completionModel
.
items
.
length
===
0
)
{
autoAcceptOracle
.
reset
();
commitCharacterController
.
reset
();
}
})
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录