提交 82211b4d 编写于 作者: J Joao Moreno

home, end in suggest

fixes #10263
上级 11d23f15
...@@ -11,5 +11,10 @@ ...@@ -11,5 +11,10 @@
"win32AppId": "{{E34003BB-9E10-4501-8C11-BE3FAA83F23F}", "win32AppId": "{{E34003BB-9E10-4501-8C11-BE3FAA83F23F}",
"win32AppUserModelId": "Microsoft.CodeOSS", "win32AppUserModelId": "Microsoft.CodeOSS",
"darwinBundleIdentifier": "com.visualstudio.code.oss", "darwinBundleIdentifier": "com.visualstudio.code.oss",
"reportIssueUrl": "https://github.com/Microsoft/vscode/issues/new" "reportIssueUrl": "https://github.com/Microsoft/vscode/issues/new",
"extensionsGallery": {
"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
"itemUrl": "https://marketplace.visualstudio.com/items"
}
} }
\ No newline at end of file
...@@ -376,6 +376,16 @@ export class List<T> implements IDisposable { ...@@ -376,6 +376,16 @@ export class List<T> implements IDisposable {
} }
} }
focusFirst(): void {
if (this.length === 0) { return; }
this.setFocus(0);
}
focusLast(): void {
if (this.length === 0) { return; }
this.setFocus(this.length - 1);
}
getFocus(): number[] { getFocus(): number[] {
return this.focus.get(); return this.focus.get();
} }
......
...@@ -148,6 +148,12 @@ export class SuggestController implements IEditorContribution { ...@@ -148,6 +148,12 @@ export class SuggestController implements IEditorContribution {
} }
} }
selectFirstSuggestion(): void {
if (this.widget) {
this.widget.selectFirst();
}
}
selectPrevSuggestion(): void { selectPrevSuggestion(): void {
if (this.widget) { if (this.widget) {
this.widget.selectPrevious(); this.widget.selectPrevious();
...@@ -160,6 +166,12 @@ export class SuggestController implements IEditorContribution { ...@@ -160,6 +166,12 @@ export class SuggestController implements IEditorContribution {
} }
} }
selectLastSuggestion(): void {
if (this.widget) {
this.widget.selectLast();
}
}
toggleSuggestionDetails(): void { toggleSuggestionDetails(): void {
if (this.widget) { if (this.widget) {
this.widget.toggleDetails(); this.widget.toggleDetails();
...@@ -254,6 +266,18 @@ CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({ ...@@ -254,6 +266,18 @@ CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
} }
})); }));
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectFirstSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectFirstSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.Home,
secondary: [KeyMod.Alt | KeyCode.Home]
}
}));
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({ CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectPrevSuggestion', id: 'selectPrevSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
...@@ -279,6 +303,18 @@ CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({ ...@@ -279,6 +303,18 @@ CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
} }
})); }));
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'selectLastSuggestion',
precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions),
handler: c => c.selectLastSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.TextFocus,
primary: KeyCode.End,
secondary: [KeyMod.Alt | KeyCode.End]
}
}));
CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({ CommonEditorRegistry.registerEditorCommand2(new SuggestCommand({
id: 'toggleSuggestionDetails', id: 'toggleSuggestionDetails',
precondition: SuggestContext.Visible, precondition: SuggestContext.Visible,
......
...@@ -283,6 +283,14 @@ class SuggestionDetails { ...@@ -283,6 +283,14 @@ class SuggestionDetails {
this.scrollUp(80); this.scrollUp(80);
} }
scrollHome(): void {
this.body.scrollTop = 0;
}
scrollEnd(): void {
this.body.scrollTop = this.body.scrollHeight;
}
private configureFont() { private configureFont() {
const fontInfo = this.editor.getConfiguration().fontInfo; const fontInfo = this.editor.getConfiguration().fontInfo;
this.title.style.fontFamily = fontInfo.fontFamily; this.title.style.fontFamily = fontInfo.fontFamily;
...@@ -663,6 +671,21 @@ export class SuggestWidget implements IContentWidget, IDisposable { ...@@ -663,6 +671,21 @@ export class SuggestWidget implements IContentWidget, IDisposable {
} }
} }
selectLast(): boolean {
switch (this.state) {
case State.Hidden:
return false;
case State.Details:
this.details.scrollEnd();
return true;
case State.Loading:
return !this.isAuto;
default:
this.list.focusLast();
return true;
}
}
selectPreviousPage(): boolean { selectPreviousPage(): boolean {
switch (this.state) { switch (this.state) {
case State.Hidden: case State.Hidden:
...@@ -693,6 +716,21 @@ export class SuggestWidget implements IContentWidget, IDisposable { ...@@ -693,6 +716,21 @@ export class SuggestWidget implements IContentWidget, IDisposable {
} }
} }
selectFirst(): boolean {
switch (this.state) {
case State.Hidden:
return false;
case State.Details:
this.details.scrollHome();
return true;
case State.Loading:
return !this.isAuto;
default:
this.list.focusFirst();
return true;
}
}
acceptSelectedSuggestion(): boolean { acceptSelectedSuggestion(): boolean {
switch (this.state) { switch (this.state) {
case State.Hidden: case State.Hidden:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册