Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish Terminal Quick Pick #32105

Merged
merged 3 commits into from
Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 40 additions & 17 deletions src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
'use strict';

import nls = require('vs/nls');
import errors = require('vs/base/common/errors');
import strings = require('vs/base/common/strings');
import scorer = require('vs/base/common/scorer');
import { TPromise } from 'vs/base/common/winjs.base';
import { Mode, IEntryRunContext, IAutoFocus, IQuickNavigateConfiguration, IModel } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenModel, QuickOpenEntryGroup, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { QuickOpenModel, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { QuickOpenHandler } from 'vs/workbench/browser/quickopen';
import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ContributableActionProvider } from 'vs/workbench/browser/actions';

export class TerminalEntry extends QuickOpenEntryGroup {
export class TerminalEntry extends QuickOpenEntry {

constructor(
private label: string,
private open: () => void
private terminalService: ITerminalService
) {
super();
}
Expand All @@ -30,23 +29,50 @@ export class TerminalEntry extends QuickOpenEntryGroup {
}

public getAriaLabel(): string {
return nls.localize('entryAriaLabel', "{0}, terminal picker", this.getLabel());
return nls.localize('termEntryAriaLabel', "{0}, terminal picker", this.getLabel());
}

public run(mode: Mode, context: IEntryRunContext): boolean {
if (mode === Mode.OPEN) {
return this.runOpen(context);
setTimeout(() => {
this.terminalService.setActiveInstanceByIndex(parseInt(this.label.split(':')[0], 10) - 1);
this.terminalService.showPanel(true);
}, 0);
return true;
}

return super.run(mode, context);
}
}

private runOpen(context: IEntryRunContext): boolean {
setTimeout(() => {
this.open();
}, 0);
export class CreateTerminal extends QuickOpenEntry {

return true;
constructor(
private label: string,
private terminalService: ITerminalService
) {
super();
}

public getLabel(): string {
return this.label;
}

public getAriaLabel(): string {
return nls.localize('termCreateEntryAriaLabel', "{0}, create new terminal", this.getLabel());
}

public run(mode: Mode, context: IEntryRunContext): boolean {
if (mode === Mode.OPEN) {
setTimeout(() => {
const newTerminal = this.terminalService.createInstance();
this.terminalService.setActiveInstance(newTerminal);
this.terminalService.showPanel(true);
}, 0);
return true;
}

return super.run(mode, context);
}
}

Expand All @@ -63,7 +89,8 @@ export class TerminalPickerHandler extends QuickOpenHandler {
searchValue = searchValue.trim();
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();

const terminalEntries = this.getTerminals();
const terminalEntries: QuickOpenEntry[] = this.getTerminals();
terminalEntries.push(new CreateTerminal(nls.localize("'workbench.action.terminal.newplus", "$(plus) Create New Integrated Terminal"), this.terminalService));

const entries = terminalEntries.filter(e => {
if (!searchValue) {
Expand All @@ -86,11 +113,7 @@ export class TerminalPickerHandler extends QuickOpenHandler {
private getTerminals(): TerminalEntry[] {
const terminals = this.terminalService.getInstanceLabels();
const terminalEntries = terminals.map(terminal => {
return new TerminalEntry(terminal, () => {
this.terminalService.showPanel(true).done(() => {
this.terminalService.setActiveInstanceByIndex(parseInt(terminal.split(':')[0], 10) - 1);
}, errors.onUnexpectedError);
});
return new TerminalEntry(terminal, this.terminalService);
});
return terminalEntries;
}
Expand Down