Fix PageUp/Down (fixes #54457)

This commit is contained in:
Christof Marti 2018-07-27 10:32:02 +02:00
parent b2c8d97d9b
commit d397db1b1a
2 changed files with 32 additions and 4 deletions

View file

@ -417,7 +417,31 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
}
break;
case KeyCode.UpArrow:
this.ui.list.focus('Previous');
if (this.ui.list.getFocusedElements().length) {
this.ui.list.focus('Previous');
} else {
this.ui.list.focus('Last');
}
if (this.canSelectMany) {
this.ui.list.domFocus();
}
break;
case KeyCode.PageDown:
if (this.ui.list.getFocusedElements().length) {
this.ui.list.focus('NextPage');
} else {
this.ui.list.focus('First');
}
if (this.canSelectMany) {
this.ui.list.domFocus();
}
break;
case KeyCode.PageUp:
if (this.ui.list.getFocusedElements().length) {
this.ui.list.focus('PreviousPage');
} else {
this.ui.list.focus('Last');
}
if (this.canSelectMany) {
this.ui.list.domFocus();
}
@ -830,7 +854,9 @@ export class QuickInputService extends Component implements IQuickInputService {
// Defer to avoid the input field reacting to the triggering key.
setTimeout(() => {
inputBox.setFocus();
list.clearFocus();
if (this.controller instanceof QuickPick && this.controller.canSelectMany) {
list.clearFocus();
}
}, 0);
}));

View file

@ -193,12 +193,14 @@ export class QuickInputList {
}
break;
case KeyCode.UpArrow:
case KeyCode.PageUp:
const focus1 = this.list.getFocus();
if (focus1.length === 1 && focus1[0] === 0) {
this._onLeave.fire();
}
break;
case KeyCode.DownArrow:
case KeyCode.PageDown:
const focus2 = this.list.getFocus();
if (focus2.length === 1 && focus2[0] === this.list.length - 1) {
this._onLeave.fire();
@ -352,10 +354,10 @@ export class QuickInputList {
return;
}
if (what === 'Next' && this.list.getFocus()[0] === this.list.length - 1) {
if ((what === 'Next' || what === 'NextPage') && this.list.getFocus()[0] === this.list.length - 1) {
what = 'First';
}
if (what === 'Previous' && this.list.getFocus()[0] === 0) {
if ((what === 'Previous' || what === 'PreviousPage') && this.list.getFocus()[0] === 0) {
what = 'Last';
}