Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
80db5680
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,发现更多精彩内容 >>
提交
80db5680
编写于
12月 10, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use bracket/block selection ranges provider, fixes #64272
上级
36961289
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
46 deletion
+29
-46
src/vs/editor/contrib/suggest/suggestModel.ts
src/vs/editor/contrib/suggest/suggestModel.ts
+0
-2
src/vs/editor/contrib/suggest/wordDistance.ts
src/vs/editor/contrib/suggest/wordDistance.ts
+29
-44
未找到文件。
src/vs/editor/contrib/suggest/suggestModel.ts
浏览文件 @
80db5680
...
...
@@ -383,8 +383,6 @@ export class SuggestModel implements IDisposable {
this
.
_requestToken
=
new
CancellationTokenSource
();
// TODO: Remove this workaround - https://github.com/Microsoft/vscode/issues/61917
// let wordDistance = Promise.resolve().then(() => WordDistance.create(this._editorWorker, this._editor));
let
wordDistance
=
WordDistance
.
create
(
this
.
_editorWorker
,
this
.
_editor
);
let
items
=
provideSuggestionItems
(
...
...
src/vs/editor/contrib/suggest/wordDistance.ts
浏览文件 @
80db5680
...
...
@@ -8,9 +8,8 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
*
as
tokenTree
from
'
vs/editor/contrib/smartSelect/tokenTree
'
;
import
{
CompletionItem
,
CompletionItemKind
}
from
'
vs/editor/common/modes
'
;
import
{
BracketSelectionRangeProvider
}
from
'
vs/editor/contrib/smartSelect/bracketSelections
'
;
export
abstract
class
WordDistance
{
...
...
@@ -35,51 +34,37 @@ export abstract class WordDistance {
return
Promise
.
resolve
(
WordDistance
.
None
);
}
// use token tree ranges
let
node
=
tokenTree
.
find
(
tokenTree
.
build
(
model
),
position
);
let
ranges
:
Range
[]
=
[];
while
(
node
)
{
if
(
!
node
.
range
.
isEmpty
())
{
ranges
.
push
(
node
.
range
);
}
if
(
node
.
end
.
lineNumber
-
node
.
start
.
lineNumber
>=
100
)
{
break
;
return
new
BracketSelectionRangeProvider
().
provideSelectionRanges
(
model
,
position
).
then
(
ranges
=>
{
if
(
!
ranges
||
ranges
.
length
===
0
)
{
return
WordDistance
.
None
;
}
node
=
node
.
parent
;
}
ranges
.
reverse
();
if
(
ranges
.
length
===
0
)
{
return
Promise
.
resolve
(
WordDistance
.
None
);
}
return
service
.
computeWordRanges
(
model
.
uri
,
ranges
[
0
]).
then
(
wordRanges
=>
{
return
new
class
extends
WordDistance
{
distance
(
anchor
:
IPosition
,
suggestion
:
CompletionItem
)
{
if
(
!
wordRanges
||
!
position
.
equals
(
editor
.
getPosition
()))
{
return
0
;
}
if
(
suggestion
.
kind
===
CompletionItemKind
.
Keyword
)
{
return
2
<<
20
;
}
let
word
=
suggestion
.
label
;
let
wordLines
=
wordRanges
[
word
];
if
(
isFalsyOrEmpty
(
wordLines
))
{
return
2
<<
20
;
}
let
idx
=
binarySearch
(
wordLines
,
Range
.
fromPositions
(
anchor
),
Range
.
compareRangesUsingStarts
);
let
bestWordRange
=
idx
>=
0
?
wordLines
[
idx
]
:
wordLines
[
Math
.
max
(
0
,
~
idx
-
1
)];
let
blockDistance
=
ranges
.
length
;
for
(
const
range
of
ranges
)
{
if
(
!
Range
.
containsRange
(
range
,
bestWordRange
))
{
break
;
return
service
.
computeWordRanges
(
model
.
uri
,
ranges
[
0
]).
then
(
wordRanges
=>
{
return
new
class
extends
WordDistance
{
distance
(
anchor
:
IPosition
,
suggestion
:
CompletionItem
)
{
if
(
!
wordRanges
||
!
position
.
equals
(
editor
.
getPosition
()))
{
return
0
;
}
if
(
suggestion
.
kind
===
CompletionItemKind
.
Keyword
)
{
return
2
<<
20
;
}
let
word
=
suggestion
.
label
;
let
wordLines
=
wordRanges
[
word
];
if
(
isFalsyOrEmpty
(
wordLines
))
{
return
2
<<
20
;
}
let
idx
=
binarySearch
(
wordLines
,
Range
.
fromPositions
(
anchor
),
Range
.
compareRangesUsingStarts
);
let
bestWordRange
=
idx
>=
0
?
wordLines
[
idx
]
:
wordLines
[
Math
.
max
(
0
,
~
idx
-
1
)];
let
blockDistance
=
ranges
.
length
;
for
(
const
range
of
ranges
)
{
if
(
!
Range
.
containsRange
(
range
,
bestWordRange
))
{
break
;
}
blockDistance
-=
1
;
}
blockDistance
-=
1
;
return
blockDistance
;
}
return
blockDistance
;
}
};
};
});
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录