Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
88b10aa0
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,发现更多精彩内容 >>
提交
88b10aa0
编写于
8月 04, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - fix overwriteBefore|After for suggestions once and then trust it
上级
6fddb785
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
12 deletion
+15
-12
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+1
-3
src/vs/editor/contrib/suggest/common/completionModel.ts
src/vs/editor/contrib/suggest/common/completionModel.ts
+2
-9
src/vs/editor/contrib/suggest/common/suggest.ts
src/vs/editor/contrib/suggest/common/suggest.ts
+12
-0
未找到文件。
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
88b10aa0
...
...
@@ -410,9 +410,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
const
item
=
e
.
elements
[
0
];
const
container
=
item
.
container
;
const
overwriteBefore
=
(
typeof
item
.
suggestion
.
overwriteBefore
===
'
undefined
'
)
?
container
.
currentWord
.
length
:
item
.
suggestion
.
overwriteBefore
;
const
overwriteAfter
=
(
typeof
item
.
suggestion
.
overwriteAfter
===
'
undefined
'
)
?
0
:
Math
.
max
(
0
,
item
.
suggestion
.
overwriteAfter
);
const
{
overwriteBefore
,
overwriteAfter
}
=
item
.
suggestion
;
this
.
model
.
accept
(
item
.
suggestion
,
overwriteBefore
,
overwriteAfter
);
alert
(
nls
.
localize
(
'
suggestionAriaAccepted
'
,
"
{0}, accepted
"
,
item
.
suggestion
.
label
));
...
...
src/vs/editor/contrib/suggest/common/completionModel.ts
浏览文件 @
88b10aa0
...
...
@@ -10,7 +10,7 @@ import {assign} from 'vs/base/common/objects';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IReadOnlyModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IFilter
,
IMatch
,
fuzzyContiguousFilter
}
from
'
vs/base/common/filters
'
;
import
{
ISuggest
Result
,
ISuggest
Support
,
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
{
ISuggestSupport
,
ISuggestion
}
from
'
vs/editor/common/modes
'
;
import
{
ISuggestionItem
}
from
'
./suggest
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -19,14 +19,12 @@ export class CompletionItem {
suggestion
:
ISuggestion
;
highlights
:
IMatch
[];
container
:
ISuggestResult
;
filter
:
IFilter
;
private
_support
:
ISuggestSupport
;
constructor
(
item
:
ISuggestionItem
)
{
this
.
suggestion
=
item
.
suggestion
;
this
.
container
=
item
.
container
;
this
.
filter
=
item
.
support
&&
item
.
support
.
filter
||
fuzzyContiguousFilter
;
this
.
_support
=
item
.
support
;
}
...
...
@@ -91,12 +89,7 @@ export class CompletionModel {
const
{
leadingLineContent
,
characterCountDelta
}
=
this
.
_lineContext
;
for
(
let
item
of
this
.
_items
)
{
let
{
overwriteBefore
}
=
item
.
suggestion
;
if
(
typeof
overwriteBefore
!==
'
number
'
)
{
overwriteBefore
=
item
.
container
.
currentWord
.
length
;
}
const
start
=
leadingLineContent
.
length
-
(
overwriteBefore
+
characterCountDelta
);
const
start
=
leadingLineContent
.
length
-
(
item
.
suggestion
.
overwriteBefore
+
characterCountDelta
);
const
word
=
leadingLineContent
.
substr
(
start
);
const
{
filter
,
suggestion
}
=
item
;
...
...
src/vs/editor/contrib/suggest/common/suggest.ts
浏览文件 @
88b10aa0
...
...
@@ -84,6 +84,9 @@ function fillInSuggestResult(bucket: ISuggestionItem[], result: ISuggestResult,
const
len
=
bucket
.
length
;
for
(
const
suggestion
of
result
.
suggestions
)
{
if
(
acceptFn
(
suggestion
))
{
fixOverwriteBeforeAfter
(
suggestion
,
result
);
bucket
.
push
({
support
,
suggestion
,
...
...
@@ -94,6 +97,15 @@ function fillInSuggestResult(bucket: ISuggestionItem[], result: ISuggestResult,
return
len
!==
bucket
.
length
;
}
function
fixOverwriteBeforeAfter
(
suggestion
:
ISuggestion
,
container
:
ISuggestResult
):
void
{
if
(
typeof
suggestion
.
overwriteBefore
!==
'
number
'
)
{
suggestion
.
overwriteBefore
=
container
.
currentWord
.
length
;
}
if
(
typeof
suggestion
.
overwriteAfter
!==
'
number
'
||
suggestion
.
overwriteAfter
<
0
)
{
suggestion
.
overwriteAfter
=
0
;
}
}
function
createSuggesionFilter
(
options
:
ISuggestOptions
):
(
candidate
:
ISuggestion
)
=>
boolean
{
if
(
options
.
snippetConfig
===
'
only
'
)
{
return
suggestion
=>
suggestion
.
type
===
'
snippet
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录