Adds paging support to repo/file quick picks

Adds keyboard support to page in repo/file quick picks
Adds progress indicator for repo/file quick picks
Completely reworks keyboard scopes
This commit is contained in:
Eric Amodio
2017-03-12 01:15:44 -05:00
parent 89a2471736
commit 487fb5197c
11 changed files with 252 additions and 174 deletions

View File

@@ -1,26 +1,32 @@
'use strict';
import { CancellationTokenSource, commands, QuickPickItem, QuickPickOptions, TextEditor, Uri, window, workspace } from 'vscode';
import { Commands, openEditor } from '../commands';
import { Commands, Keyboard, KeyboardScope, KeyMapping, openEditor } from '../commands';
import { IAdvancedConfig } from '../configuration';
import { Logger } from '../logger';
// import { Logger } from '../logger';
export function getQuickPickIgnoreFocusOut() {
return !workspace.getConfiguration('gitlens').get<IAdvancedConfig>('advanced').quickPick.closeOnFocusOut;
}
export function showQuickPickProgress(message: string): CancellationTokenSource {
export function showQuickPickProgress(message: string, mapping?: KeyMapping): CancellationTokenSource {
const cancellation = new CancellationTokenSource();
_showQuickPickProgress(message, cancellation);
_showQuickPickProgress(message, cancellation, mapping);
return cancellation;
}
async function _showQuickPickProgress(message: string, cancellation: CancellationTokenSource) {
Logger.log(`showQuickPickProgress`, `show`, message);
async function _showQuickPickProgress(message: string, cancellation: CancellationTokenSource, mapping?: KeyMapping) {
// Logger.log(`showQuickPickProgress`, `show`, message);
const scope: KeyboardScope = mapping && await Keyboard.instance.beginScope(mapping);
await window.showQuickPick(_getInfiniteCancellablePromise(cancellation), {
placeHolder: message,
ignoreFocusOut: getQuickPickIgnoreFocusOut()
} as QuickPickOptions, cancellation.token);
Logger.log(`showQuickPickProgress`, `cancel`, message);
// Logger.log(`showQuickPickProgress`, `cancel`, message);
scope && scope.dispose();
cancellation.cancel();
}
@@ -28,7 +34,7 @@ function _getInfiniteCancellablePromise(cancellation: CancellationTokenSource) {
return new Promise((resolve, reject) => {
const disposable = cancellation.token.onCancellationRequested(() => {
disposable.dispose();
reject();
resolve([]);
});
});
}
@@ -55,17 +61,6 @@ export class KeyCommandQuickPickItem extends CommandQuickPickItem {
}
}
export class KeyNoopCommandQuickPickItem extends CommandQuickPickItem {
constructor() {
super({ label: undefined, description: undefined }, undefined, undefined);
}
execute(): Thenable<{}> {
return Promise.resolve(undefined);
}
}
export class OpenFileCommandQuickPickItem extends CommandQuickPickItem {
constructor(public uri: Uri, item: QuickPickItem) {