Added focusFirst / focusLast methods for IntelliSense dropdown. Support for...

Added focusFirst / focusLast methods for IntelliSense dropdown. Support for details view/state is yet to come.
上级 e3d6c5d6
......@@ -390,6 +390,16 @@ export class List<T> implements IDisposable {
}
}
focusLast(): void {
if (this.length === 0) { return; }
this.setFocus([this.length - 1]);
}
focusFirst(): void {
if (this.length === 0) { return; }
this.setFocus([0]);
}
getFocus(): number[] {
return this.focus.get();
}
......
......@@ -199,6 +199,12 @@ export class SuggestController implements IEditorContribution {
}
}
selectLastSuggestion(): void {
if (this.widget) {
this.widget.selectLast();
}
}
selectPrevSuggestion(): void {
if (this.widget) {
this.widget.selectPrevious();
......@@ -211,6 +217,12 @@ export class SuggestController implements IEditorContribution {
}
}
selectFirstSuggestion(): void {
if (this.widget) {
this.widget.selectFirst();
}
}
toggleSuggestionDetails(): void {
if (this.widget) {
this.widget.toggleDetails();
......@@ -310,6 +322,17 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
}
}));
CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
id: 'selectLastSuggestion',
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectLastSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.End
}
}));
CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
id: 'selectPrevSuggestion',
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
......@@ -335,6 +358,17 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
}
}));
CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
id: 'selectFirstSuggestion',
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectFirstSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Home
}
}));
CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
id: 'toggleSuggestionDetails',
precondition: SuggestContext.Visible,
......
......@@ -634,6 +634,22 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
}
}
selectLast(): boolean {
switch (this.state) {
case State.Hidden:
return false;
case State.Details:
// Not worried about details just yet...
// this.details.pageDown();
return true;
case State.Loading:
return !this.isAuto;
default:
this.list.focusLast();
return true;
}
}
selectPreviousPage(): boolean {
switch (this.state) {
case State.Hidden:
......@@ -665,6 +681,22 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
}
}
selectFirst(): boolean {
switch (this.state) {
case State.Hidden:
return false;
case State.Details:
// Not worried about details just yet...
// this.details.pageUp();
return true;
case State.Loading:
return !this.isAuto;
default:
this.list.focusFirst();
return true;
}
}
getFocusedItem(): ICompletionItem {
if (this.state !== State.Hidden
&& this.state !== State.Empty
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册