Merge from vscode 8df646d3c5477b02737fc10343fa7cf0cc3f606b

This commit is contained in:
ADS Merger
2020-03-25 06:20:54 +00:00
parent 6e5fbc9012
commit d810da9d87
114 changed files with 2036 additions and 797 deletions

View File

@@ -9,10 +9,19 @@ export class QuickInput {
static QUICK_INPUT = '.quick-input-widget';
static QUICK_INPUT_INPUT = `${QuickInput.QUICK_INPUT} .quick-input-box input`;
static QUICK_INPUT_FOCUSED_ELEMENT = `${QuickInput.QUICK_INPUT} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
static QUICK_INPUT_ROW = `${QuickInput.QUICK_INPUT} .quick-input-list .monaco-list-row`;
static QUICK_INPUT_FOCUSED_ELEMENT = `${QuickInput.QUICK_INPUT_ROW}.focused .monaco-highlighted-label`;
static QUICK_INPUT_ENTRY_LABEL = `${QuickInput.QUICK_INPUT_ROW} .label-name`;
static QUICK_INPUT_ENTRY_LABEL_SPAN = `${QuickInput.QUICK_INPUT_ROW} .monaco-highlighted-label span`;
constructor(private code: Code) { }
async submit(text: string): Promise<void> {
await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, text);
await this.code.dispatchKeybinding('enter');
await this.waitForQuickInputClosed();
}
async closeQuickInput(): Promise<void> {
await this.code.dispatchKeybinding('escape');
await this.waitForQuickInputClosed();
@@ -22,7 +31,11 @@ export class QuickInput {
await this.code.waitForActiveElement(QuickInput.QUICK_INPUT_INPUT, retryCount);
}
private async waitForQuickInputClosed(): Promise<void> {
async waitForQuickInputElements(accept: (names: string[]) => boolean): Promise<void> {
await this.code.waitForElements(QuickInput.QUICK_INPUT_ENTRY_LABEL, false, els => accept(els.map(e => e.textContent)));
}
async waitForQuickInputClosed(): Promise<void> {
await this.code.waitForElement(QuickInput.QUICK_INPUT, r => !!r && r.attributes.style.indexOf('display: none;') !== -1);
}

View File

@@ -5,17 +5,11 @@
import { Editors } from './editors';
import { Code } from './code';
import { QuickInput } from './quickinput';
export class QuickOpen {
static QUICK_OPEN = 'div.monaco-quick-open-widget';
static QUICK_OPEN_HIDDEN = 'div.monaco-quick-open-widget[aria-hidden="true"]';
static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-open-input input`;
static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry';
static QUICK_OPEN_ENTRY_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name';
constructor(private code: Code, private editors: Editors) { }
constructor(private code: Code, private editors: Editors, private quickInput: QuickInput) { }
async openQuickOpen(value: string): Promise<void> {
let retries = 0;
@@ -29,7 +23,7 @@ export class QuickOpen {
}
try {
await this.waitForQuickOpenOpened(10);
await this.quickInput.waitForQuickInputOpened(10);
break;
} catch (err) {
if (++retries > 5) {
@@ -41,59 +35,27 @@ export class QuickOpen {
}
if (value) {
await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, value);
await this.code.waitForSetValue(QuickInput.QUICK_INPUT_INPUT, value);
}
}
async closeQuickOpen(): Promise<void> {
await this.code.dispatchKeybinding('escape');
await this.waitForQuickOpenClosed();
}
async openFile(fileName: string): Promise<void> {
await this.openQuickOpen(fileName);
await this.waitForQuickOpenElements(names => names[0] === fileName);
await this.quickInput.waitForQuickInputElements(names => names[0] === fileName);
await this.code.dispatchKeybinding('enter');
await this.editors.waitForActiveTab(fileName);
await this.editors.waitForEditorFocus(fileName);
}
async waitForQuickOpenOpened(retryCount?: number): Promise<void> {
await this.code.waitForActiveElement(QuickOpen.QUICK_OPEN_INPUT, retryCount);
}
private async waitForQuickOpenClosed(): Promise<void> {
await this.code.waitForElement(QuickOpen.QUICK_OPEN_HIDDEN);
}
async submit(text: string): Promise<void> {
await this.code.waitForSetValue(QuickOpen.QUICK_OPEN_INPUT, text);
await this.code.dispatchKeybinding('enter');
await this.waitForQuickOpenClosed();
}
async selectQuickOpenElement(index: number): Promise<void> {
await this.waitForQuickOpenOpened();
for (let from = 0; from < index; from++) {
await this.code.dispatchKeybinding('down');
}
await this.code.dispatchKeybinding('enter');
await this.waitForQuickOpenClosed();
}
async waitForQuickOpenElements(accept: (names: string[]) => boolean): Promise<void> {
await this.code.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_LABEL_SELECTOR, false, els => accept(els.map(e => e.textContent)));
}
async runCommand(command: string): Promise<void> {
await this.openQuickOpen(`> ${command}`);
async runCommand(commandId: string): Promise<void> {
await this.openQuickOpen(`>${commandId}`);
// wait for best choice to be focused
await this.code.waitForTextContent(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT, command);
await this.code.waitForTextContent(QuickInput.QUICK_INPUT_FOCUSED_ELEMENT);
// wait and click on best choice
await this.code.waitAndClick(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT);
await this.quickInput.selectQuickInputElement(0);
}
async openQuickOutline(): Promise<void> {
@@ -106,13 +68,13 @@ export class QuickOpen {
await this.code.dispatchKeybinding('ctrl+shift+o');
}
const text = await this.code.waitForTextContent('div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties div.monaco-tree-row .quick-open-entry .monaco-icon-label .label-name .monaco-highlighted-label span');
const text = await this.code.waitForTextContent(QuickInput.QUICK_INPUT_ENTRY_LABEL_SPAN);
if (text !== 'No symbol information for the file') {
return;
}
await this.closeQuickOpen();
await this.quickInput.closeQuickInput();
await new Promise(c => setTimeout(c, 250));
}
}

View File

@@ -32,6 +32,6 @@ export class SettingsEditor {
}
private async openSettings(): Promise<void> {
await this.quickopen.runCommand('Preferences: Open Settings (JSON)');
await this.quickopen.runCommand('workbench.action.openSettingsJson');
}
}

View File

@@ -4,32 +4,16 @@
*--------------------------------------------------------------------------------------------*/
import { Editors } from '../editors';
import { QuickOpen } from '../quickopen';
import { Code } from '../code';
import * as path from 'path';
export class QueryEditors extends Editors {
constructor(
private vsCode: Code,
private quickopen: QuickOpen
private vsCode: Code
) {
super(vsCode);
}
/**
* Opens the specified file - this correctly handles SQL files which are opened in a Query Editor window
* @param filePath The full path of the file to open.
*/
async openFile(filePath: string): Promise<void> {
await this.quickopen.openQuickOpen(filePath);
const fileBaseName = path.basename(filePath);
await this.quickopen.waitForQuickOpenElements(names => names[0] === fileBaseName);
await this.vsCode.dispatchKeybinding('enter');
await this.waitForEditorFocus(fileBaseName);
}
/**
* Waits for an active SQL Query Editor tab for the specified file. This is a modification of the editors.waitForActiveTab that
* takes into account the connected status displayed in the title of Query Editors.
@@ -41,7 +25,6 @@ export class QueryEditors extends Editors {
await this.vsCode.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName} - disconnected, tab"]`);
}
/**
* Waits for an active Query Editor for the specified file to have focus. This is a modification of the editors.waitForEditorFocus
* that takes into account the connected status displayed in the title of Query Editors.

View File

@@ -15,7 +15,7 @@ export class Terminal {
constructor(private code: Code, private quickopen: QuickOpen) { }
async showTerminal(): Promise<void> {
await this.quickopen.runCommand('View: Toggle Integrated Terminal');
await this.quickopen.runCommand('workbench.action.terminal.toggleTerminal');
await this.code.waitForActiveElement(XTERM_TEXTAREA);
await this.code.waitForTerminalBuffer(XTERM_SELECTOR, lines => lines.some(line => line.length > 0));
}

View File

@@ -56,8 +56,8 @@ export class Workbench {
constructor(code: Code, userDataPath: string) {
this.editors = new Editors(code);
this.quickopen = new QuickOpen(code, this.editors);
this.quickinput = new QuickInput(code);
this.quickopen = new QuickOpen(code, this.editors, this.quickinput);
this.explorer = new Explorer(code, this.editors);
this.activitybar = new ActivityBar(code);
this.search = new Search(code);
@@ -73,7 +73,7 @@ export class Workbench {
// {{SQL CARBON EDIT}}
this.connectionDialog = new ConnectionDialog(code);
this.profiler = new Profiler(code, this.quickopen);
this.queryEditors = new QueryEditors(code, this.quickopen);
this.queryEditors = new QueryEditors(code);
// {{END}}
}
}