Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
10ead5ff
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,发现更多精彩内容 >>
提交
10ead5ff
编写于
2月 08, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
suggest: next, previous
上级
6b495479
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
123 addition
and
77 deletion
+123
-77
src/vs/base/browser/ui/list/listWidget.ts
src/vs/base/browser/ui/list/listWidget.ts
+42
-0
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+81
-77
未找到文件。
src/vs/base/browser/ui/list/listWidget.ts
浏览文件 @
10ead5ff
...
@@ -109,6 +109,18 @@ class Trait implements IDisposable {
...
@@ -109,6 +109,18 @@ class Trait implements IDisposable {
return
this
.
indexes
.
some
(
i
=>
i
===
index
);
return
this
.
indexes
.
some
(
i
=>
i
===
index
);
}
}
next
(
n
:
number
):
void
{
let
index
=
this
.
indexes
.
length
?
this
.
indexes
[
0
]
:
0
;
index
=
Math
.
min
(
index
+
n
,
this
.
indexes
.
length
);
this
.
set
(
index
);
}
previous
(
n
:
number
):
void
{
let
index
=
this
.
indexes
.
length
?
this
.
indexes
[
0
]
:
this
.
indexes
.
length
-
1
;
index
=
Math
.
max
(
index
-
n
,
0
);
this
.
set
(
index
);
}
wrapRenderer
<
T
,
D
>
(
renderer
:
IRenderer
<
T
,
D
>
):
IRenderer
<
T
,
ITraitTemplateData
<
D
>>
{
wrapRenderer
<
T
,
D
>
(
renderer
:
IRenderer
<
T
,
D
>
):
IRenderer
<
T
,
ITraitTemplateData
<
D
>>
{
return
new
TraitRenderer
<
T
,
D
>
(
this
,
renderer
);
return
new
TraitRenderer
<
T
,
D
>
(
this
,
renderer
);
}
}
...
@@ -202,11 +214,41 @@ export class List<T> implements IDisposable {
...
@@ -202,11 +214,41 @@ export class List<T> implements IDisposable {
indexes
.
forEach
(
i
=>
this
.
view
.
splice
(
i
,
1
,
this
.
view
.
element
(
i
)));
indexes
.
forEach
(
i
=>
this
.
view
.
splice
(
i
,
1
,
this
.
view
.
element
(
i
)));
}
}
selectNext
(
n
=
1
,
loop
=
false
):
void
{
if
(
this
.
length
===
0
)
return
;
const
selection
=
this
.
selection
.
get
();
let
index
=
selection
.
length
>
0
?
selection
[
0
]
+
n
:
0
;
this
.
selection
.
set
(
loop
?
index
%
this
.
length
:
Math
.
min
(
index
,
this
.
length
-
1
));
}
selectPrevious
(
n
=
1
,
loop
=
false
):
void
{
if
(
this
.
length
===
0
)
return
;
const
selection
=
this
.
selection
.
get
();
let
index
=
selection
.
length
>
0
?
selection
[
0
]
-
n
:
0
;
if
(
loop
&&
index
<
0
)
index
=
this
.
length
+
(
index
%
this
.
length
);
this
.
selection
.
set
(
Math
.
max
(
index
,
0
));
}
setFocus
(...
indexes
:
number
[]):
void
{
setFocus
(...
indexes
:
number
[]):
void
{
indexes
=
indexes
.
concat
(
this
.
focus
.
set
(...
indexes
));
indexes
=
indexes
.
concat
(
this
.
focus
.
set
(...
indexes
));
indexes
.
forEach
(
i
=>
this
.
view
.
splice
(
i
,
1
,
this
.
view
.
element
(
i
)));
indexes
.
forEach
(
i
=>
this
.
view
.
splice
(
i
,
1
,
this
.
view
.
element
(
i
)));
}
}
focusNext
(
n
=
1
,
loop
=
false
):
void
{
if
(
this
.
length
===
0
)
return
;
const
focus
=
this
.
focus
.
get
();
let
index
=
focus
.
length
>
0
?
focus
[
0
]
+
n
:
0
;
this
.
focus
.
set
(
loop
?
index
%
this
.
length
:
Math
.
min
(
index
,
this
.
length
-
1
));
}
focusPrevious
(
n
=
1
,
loop
=
false
):
void
{
if
(
this
.
length
===
0
)
return
;
const
focus
=
this
.
focus
.
get
();
let
index
=
focus
.
length
>
0
?
focus
[
0
]
-
n
:
0
;
if
(
loop
&&
index
<
0
)
index
=
this
.
length
+
(
index
%
this
.
length
);
this
.
focus
.
set
(
Math
.
max
(
index
,
0
));
}
getFocus
():
T
[]
{
getFocus
():
T
[]
{
return
this
.
focus
.
get
().
map
(
i
=>
this
.
view
.
element
(
i
));
return
this
.
focus
.
get
().
map
(
i
=>
this
.
view
.
element
(
i
));
}
}
...
...
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
10ead5ff
...
@@ -426,7 +426,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -426,7 +426,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
private
suggestionSupportsAutoAccept
:
IKeybindingContextKey
<
boolean
>
;
private
suggestionSupportsAutoAccept
:
IKeybindingContextKey
<
boolean
>
;
private
loadingTimeout
:
number
;
private
loadingTimeout
:
number
;
private
currentSuggestionDetails
:
TPromise
<
CompletionItem
>
;
private
currentSuggestionDetails
:
TPromise
<
CompletionItem
>
;
private
oldFocus
:
CompletionItem
;
private
focusedItem
:
CompletionItem
;
private
completionModel
:
CompletionModel
;
private
completionModel
:
CompletionModel
;
private
telemetryData
:
ITelemetryData
;
private
telemetryData
:
ITelemetryData
;
...
@@ -453,7 +453,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -453,7 +453,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
@
IInstantiationService
instantiationService
:
IInstantiationService
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{
)
{
this
.
isAuto
=
false
;
this
.
isAuto
=
false
;
this
.
oldFocus
=
null
;
this
.
focusedItem
=
null
;
this
.
suggestionSupportsAutoAccept
=
keybindingService
.
createKey
(
CONTEXT_SUGGESTION_SUPPORTS_ACCEPT_ON_KEY
,
true
);
this
.
suggestionSupportsAutoAccept
=
keybindingService
.
createKey
(
CONTEXT_SUGGESTION_SUPPORTS_ACCEPT_ON_KEY
,
true
);
this
.
telemetryData
=
null
;
this
.
telemetryData
=
null
;
...
@@ -484,7 +484,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -484,7 +484,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
SuggestRegistry
.
onDidChange
(()
=>
this
.
onModelModeChanged
()),
SuggestRegistry
.
onDidChange
(()
=>
this
.
onModelModeChanged
()),
// editor.addListener2(EditorCommon.EventType.EditorTextBlur, () => this.onEditorBlur()),
// editor.addListener2(EditorCommon.EventType.EditorTextBlur, () => this.onEditorBlur()),
this
.
list
.
onSelectionChange
(
e
=>
this
.
onListSelection
(
e
)),
this
.
list
.
onSelectionChange
(
e
=>
this
.
onListSelection
(
e
)),
// this.list.addListener2('focus', e => this.onTree
Focus(e)),
this
.
list
.
onFocusChange
(
e
=>
this
.
onList
Focus
(
e
)),
this
.
editor
.
addListener2
(
EditorCommon
.
EventType
.
CursorSelectionChanged
,
()
=>
this
.
onCursorSelectionChanged
()),
this
.
editor
.
addListener2
(
EditorCommon
.
EventType
.
CursorSelectionChanged
,
()
=>
this
.
onCursorSelectionChanged
()),
this
.
model
.
onDidTrigger
(
e
=>
this
.
onDidTrigger
(
e
)),
this
.
model
.
onDidTrigger
(
e
=>
this
.
onDidTrigger
(
e
)),
this
.
model
.
onDidSuggest
(
e
=>
this
.
onDidSuggest
(
e
)),
this
.
model
.
onDidSuggest
(
e
=>
this
.
onDidSuggest
(
e
)),
...
@@ -533,35 +533,47 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -533,35 +533,47 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
},
0
);
},
0
);
}
}
// private onTreeFocus(e: Tree.IFocusEvent): void {
private
onListFocus
(
e
:
IFocusChangeEvent
<
CompletionItem
>
):
void
{
// const focus = e.focus;
if
(
!
e
.
elements
.
length
)
{
// const payload = e.payload;
return
;
}
// if (focus instanceof CompletionItem) {
const
item
=
e
.
elements
[
0
];
// this.resolveDetails(<CompletionItem>focus);
// this.suggestionSupportsAutoAccept.set(!(<CompletionItem>focus).suggestion.noAutoAccept);
// }
// const elementsToRefresh: any[] = [];
if
(
item
===
this
.
focusedItem
)
{
return
;
}
// if (this.oldFocus) {
const
index
=
e
.
indexes
[
0
];
// elementsToRefresh.push(this.oldFocus);
// const payload = e.payload;
// }
// if (focus) {
this
.
resolveDetails
(
item
,
index
);
// elementsToRefresh.push(focus);
this
.
suggestionSupportsAutoAccept
.
set
(
!
(
<
CompletionItem
>
item
).
suggestion
.
noAutoAccept
);
// }
// this.oldFocus = focus;
if
(
this
.
focusedItem
)
{
const
index
=
this
.
completionModel
.
items
.
indexOf
(
this
.
focusedItem
);
if
(
index
>
-
1
)
this
.
list
.
splice
(
index
,
1
,
this
.
focusedItem
);
this
.
focusedItem
=
null
;
}
// this.list.refreshAll(elementsToRefresh).done(() => {
if
(
item
)
{
// this.updateWidgetHeight();
this
.
focusedItem
=
item
;
this
.
list
.
splice
(
index
,
1
,
item
);
this
.
list
.
setFocus
(
index
);
}
// if (focus) {
this
.
updateWidgetHeight
();
// return this.list.reveal(focus, (payload && payload.firstSuggestion) ? 0 : null);
// }
if
(
item
)
{
// }, onUnexpectedError);
this
.
list
.
reveal
(
index
);
// }
}
// this.list.refreshAll(elementsToRefresh).done(() => {
// if (item) {
// return this.list.reveal(item, (payload && payload.firstSuggestion) ? 0 : null);
// }
// }, onUnexpectedError);
}
private
onModelModeChanged
():
void
{
private
onModelModeChanged
():
void
{
const
model
=
this
.
editor
.
getModel
();
const
model
=
this
.
editor
.
getModel
();
...
@@ -737,26 +749,28 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -737,26 +749,28 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
}
}
}
}
// private resolveDetails(item: CompletionItem
): void {
private
resolveDetails
(
item
:
CompletionItem
,
index
:
number
):
void
{
// if (!item
) {
if
(
this
.
currentSuggestionDetails
)
{
// return
;
this
.
currentSuggestionDetails
.
cancel
()
;
//
}
}
// if (this.currentSuggestionDetails) {
this
.
currentSuggestionDetails
=
item
.
resolveDetails
(
// this.currentSuggestionDetails.cancel();
this
.
editor
.
getModel
().
getAssociatedResource
(),
// }
this
.
model
.
getRequestPosition
()
||
this
.
editor
.
getPosition
()
);
// this.currentSuggestionDetails = item.resolveDetails(
this
.
currentSuggestionDetails
.
then
(()
=>
{
// this.editor.getModel().getAssociatedResource(),
this
.
currentSuggestionDetails
=
undefined
;
// this.model.getRequestPosition() || this.editor.getPosition()
// );
// this.currentSuggestionDetails.then(() => {
if
(
item
===
this
.
focusedItem
)
{
// this.currentSuggestionDetails = undefined;
this
.
list
.
splice
(
index
,
1
,
item
);
// return this.list.refresh(item).then(() => this.updateWidgetHeight());
this
.
list
.
setFocus
(
index
);
// })
this
.
updateWidgetHeight
();
// .done(null, err => !isPromiseCanceledError(err) && onUnexpectedError(err));
}
// }
},
err
=>
!
isPromiseCanceledError
(
err
)
&&
onUnexpectedError
(
err
)
);
}
public
selectNextPage
():
boolean
{
public
selectNextPage
():
boolean
{
return
false
;
return
false
;
...
@@ -775,23 +789,18 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -775,23 +789,18 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
}
}
public
selectNext
():
boolean
{
public
selectNext
():
boolean
{
return
false
;
switch
(
this
.
state
)
{
// switch (this.state) {
case
State
.
Hidden
:
// case State.Hidden:
return
false
;
// return false;
case
State
.
Details
:
// case State.Details:
this
.
details
.
scrollDown
();
// this.details.scrollDown();
return
true
;
// return true;
case
State
.
Loading
:
// case State.Loading:
return
!
this
.
isAuto
;
// return !this.isAuto;
default
:
// default:
this
.
list
.
focusNext
(
1
,
true
);
// const focus = this.list.getFocus();
return
true
;
// this.list.focusNext(1);
}
// if (focus === this.list.getFocus()) {
// this.list.focusFirst();
// }
// return true;
// }
}
}
public
selectPreviousPage
():
boolean
{
public
selectPreviousPage
():
boolean
{
...
@@ -811,23 +820,18 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -811,23 +820,18 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
}
}
public
selectPrevious
():
boolean
{
public
selectPrevious
():
boolean
{
return
false
;
switch
(
this
.
state
)
{
// switch (this.state) {
case
State
.
Hidden
:
// case State.Hidden:
return
false
;
// return false;
case
State
.
Details
:
// case State.Details:
this
.
details
.
scrollUp
();
// this.details.scrollUp();
return
true
;
// return true;
case
State
.
Loading
:
// case State.Loading:
return
!
this
.
isAuto
;
// return !this.isAuto;
default
:
// default:
this
.
list
.
focusPrevious
(
1
,
true
);
// const focus = this.list.getFocus();
return
true
;
// this.list.focusPrevious(1);
}
// if (focus === this.list.getFocus()) {
// this.list.focusLast();
// }
// return true;
// }
}
}
public
acceptSelectedSuggestion
():
boolean
{
public
acceptSelectedSuggestion
():
boolean
{
...
@@ -951,7 +955,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
...
@@ -951,7 +955,7 @@ export class SuggestWidget implements EditorBrowser.IContentWidget, IDisposable
this
.
state
=
null
;
this
.
state
=
null
;
this
.
suggestionSupportsAutoAccept
=
null
;
this
.
suggestionSupportsAutoAccept
=
null
;
this
.
currentSuggestionDetails
=
null
;
this
.
currentSuggestionDetails
=
null
;
this
.
oldFocus
=
null
;
this
.
focusedItem
=
null
;
this
.
telemetryData
=
null
;
this
.
telemetryData
=
null
;
this
.
telemetryService
=
null
;
this
.
telemetryService
=
null
;
this
.
telemetryTimer
=
null
;
this
.
telemetryTimer
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录