Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5afc55a7
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,发现更多精彩内容 >>
提交
5afc55a7
编写于
8月 09, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
keep recently used item selected as long as it's in the top suggestions group, #78571
上级
642d3a08
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
49 addition
and
17 deletion
+49
-17
src/vs/editor/contrib/suggest/suggestMemory.ts
src/vs/editor/contrib/suggest/suggestMemory.ts
+26
-17
src/vs/editor/contrib/suggest/test/suggestMemory.test.ts
src/vs/editor/contrib/suggest/test/suggestMemory.test.ts
+23
-0
未找到文件。
src/vs/editor/contrib/suggest/suggestMemory.ts
浏览文件 @
5afc55a7
...
...
@@ -22,10 +22,10 @@ export abstract class Memory {
if
(
items
.
length
===
0
)
{
return
0
;
}
let
topScore
=
items
[
0
].
score
;
let
topScore
=
items
[
0
].
score
[
0
]
;
for
(
let
i
=
1
;
i
<
items
.
length
;
i
++
)
{
const
{
score
,
completion
:
suggestion
}
=
items
[
i
];
if
(
score
!==
topScore
)
{
if
(
score
[
0
]
!==
topScore
)
{
// stop when leaving the group of top matches
break
;
}
...
...
@@ -81,33 +81,42 @@ export class LRUMemory extends Memory {
}
select
(
model
:
ITextModel
,
pos
:
IPosition
,
items
:
CompletionItem
[]):
number
{
// in order of completions, select the first
// that has been used in the past
let
{
word
}
=
model
.
getWordUntilPosition
(
pos
);
if
(
word
.
length
!==
0
)
{
return
super
.
select
(
model
,
pos
,
items
);
if
(
items
.
length
===
0
)
{
return
0
;
}
le
t
lineSuffix
=
model
.
getLineContent
(
pos
.
lineNumber
).
substr
(
pos
.
column
-
10
,
pos
.
column
-
1
);
cons
t
lineSuffix
=
model
.
getLineContent
(
pos
.
lineNumber
).
substr
(
pos
.
column
-
10
,
pos
.
column
-
1
);
if
(
/
\s
$/
.
test
(
lineSuffix
))
{
return
super
.
select
(
model
,
pos
,
items
);
}
let
res
=
-
1
;
let
topScore
=
items
[
0
].
score
[
0
];
let
indexPreselect
=
-
1
;
let
indexRecency
=
-
1
;
let
seq
=
-
1
;
for
(
let
i
=
0
;
i
<
items
.
length
;
i
++
)
{
const
{
completion
:
suggestion
}
=
items
[
i
];
const
key
=
`
${
model
.
getLanguageIdentifier
().
language
}
/
${
suggestion
.
label
}
`
;
const
item
=
this
.
_cache
.
get
(
key
);
if
(
item
&&
item
.
touch
>
seq
&&
item
.
type
===
suggestion
.
kind
&&
item
.
insertText
===
suggestion
.
insertText
)
{
if
(
items
[
i
].
score
[
0
]
!==
topScore
)
{
// consider only top items
break
;
}
const
key
=
`
${
model
.
getLanguageIdentifier
().
language
}
/
${
items
[
i
].
completion
.
label
}
`
;
const
item
=
this
.
_cache
.
peek
(
key
);
if
(
item
&&
item
.
touch
>
seq
&&
item
.
type
===
items
[
i
].
completion
.
kind
&&
item
.
insertText
===
items
[
i
].
completion
.
insertText
)
{
seq
=
item
.
touch
;
res
=
i
;
indexRecency
=
i
;
}
if
(
items
[
i
].
completion
.
preselect
&&
indexPreselect
===
-
1
)
{
// stop when seeing an auto-select-item
return
indexPreselect
=
i
;
}
if
(
res
===
-
1
)
{
return
super
.
select
(
model
,
pos
,
items
);
}
if
(
indexRecency
!==
-
1
)
{
return
indexRecency
;
}
else
if
(
indexPreselect
!==
-
1
)
{
return
indexPreselect
;
}
else
{
return
res
;
return
0
;
}
}
...
...
src/vs/editor/contrib/suggest/test/suggestMemory.test.ts
浏览文件 @
5afc55a7
...
...
@@ -101,6 +101,29 @@ suite('SuggestMemories', function () {
]),
0
);
});
test
(
'
`"editor.suggestSelection": "recentlyUsed"` should be a little more sticky #78571
'
,
function
()
{
let
item1
=
createSuggestItem
(
'
gamma
'
,
0
);
let
item2
=
createSuggestItem
(
'
game
'
,
0
);
items
=
[
item1
,
item2
];
let
mem
=
new
LRUMemory
();
buffer
.
setValue
(
'
foo.
'
);
mem
.
memorize
(
buffer
,
{
lineNumber
:
1
,
column
:
1
},
item2
);
assert
.
equal
(
mem
.
select
(
buffer
,
{
lineNumber
:
1
,
column
:
2
},
items
),
0
);
// leading whitespace -> ignore recent items
mem
.
memorize
(
buffer
,
{
lineNumber
:
1
,
column
:
9
},
item2
);
assert
.
equal
(
mem
.
select
(
buffer
,
{
lineNumber
:
1
,
column
:
9
},
items
),
1
);
// foo.
buffer
.
setValue
(
'
foo.g
'
);
assert
.
equal
(
mem
.
select
(
buffer
,
{
lineNumber
:
1
,
column
:
10
},
items
),
1
);
// foo.g, 'gamma' and 'game' have the same score
item1
.
score
=
[
10
,
0
,
0
];
assert
.
equal
(
mem
.
select
(
buffer
,
{
lineNumber
:
1
,
column
:
10
},
items
),
0
);
// foo.g, 'gamma' has higher score
});
test
(
'
intellisense is not showing top options first #43429
'
,
function
()
{
// ensure we don't memorize for whitespace prefixes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录