提交 a55f3eb6 编写于 作者: J Joao Moreno

Merge branch 'autocompleteHomeEndSupport' of https://github.com/mlewand/vscode...

Merge branch 'autocompleteHomeEndSupport' of https://github.com/mlewand/vscode into mlewand-autocompleteHomeEndSupport
......@@ -716,6 +716,16 @@ export class List<T> implements ISpliceable<T>, 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();
}
......
......@@ -226,6 +226,12 @@ export class SuggestController implements IEditorContribution {
}
}
selectLastSuggestion(): void {
if (this.widget) {
this.widget.selectLast();
}
}
selectPrevSuggestion(): void {
if (this.widget) {
this.widget.selectPrevious();
......@@ -238,6 +244,12 @@ export class SuggestController implements IEditorContribution {
}
}
selectFirstSuggestion(): void {
if (this.widget) {
this.widget.selectFirst();
}
}
toggleSuggestionDetails(): void {
if (this.widget) {
this.widget.toggleDetails();
......@@ -337,6 +349,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),
......@@ -362,6 +385,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,
......
......@@ -266,6 +266,14 @@ class SuggestionDetails {
this.body.scrollTop -= much;
}
scrollTop(): void {
this.body.scrollTop = 0;
}
scrollBottom(): void {
this.body.scrollTop = this.body.scrollHeight;
}
pageDown(): void {
this.scrollDown(80);
}
......@@ -661,6 +669,21 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
}
}
selectLast(): boolean {
switch (this.state) {
case State.Hidden:
return false;
case State.Details:
this.details.scrollBottom();
return true;
case State.Loading:
return !this.isAuto;
default:
this.list.focusLast();
return true;
}
}
selectPreviousPage(): boolean {
switch (this.state) {
case State.Hidden:
......@@ -692,6 +715,21 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
}
}
selectFirst(): boolean {
switch (this.state) {
case State.Hidden:
return false;
case State.Details:
this.details.scrollTop();
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.
先完成此消息的编辑!
想要评论请 注册