Keybinding for Show SQL Pane (#9750)

* WIP registerKeybind

* testing command

* Moved command to query.contribution

* Moved command to editData.contribution

* simplified command

* more simplification

* Working keybind for toggle query pane added.

* removed space

* added option to always show sql pane

* removed keybind default and changed option
This commit is contained in:
Alex Ma
2020-05-14 14:06:58 -07:00
committed by GitHub
parent e3218ade02
commit 8f7861deac
3 changed files with 42 additions and 1 deletions

View File

@@ -5,11 +5,16 @@
import { EditDataEditor } from 'sql/workbench/contrib/editData/browser/editDataEditor';
import { EditDataInput } from 'sql/workbench/browser/editData/editDataInput';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { EditDataResultsEditor } from 'sql/workbench/contrib/editData/browser/editDataResultsEditor';
import { EditDataResultsInput } from 'sql/workbench/browser/editData/editDataResultsInput';
import { EditorDescriptor, IEditorRegistry, Extensions } from 'vs/workbench/browser/editor';
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import * as editDataActions from 'sql/workbench/contrib/editData/browser/editDataActions';
import * as nls from 'vs/nls';
// Editor
const editDataEditorDescriptor = EditorDescriptor.create(
@@ -18,6 +23,20 @@ const editDataEditorDescriptor = EditorDescriptor.create(
'EditData'
);
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': 'showEditDataSqlPaneOnStartup',
'title': nls.localize('showEditDataSqlPaneOnStartup', 'Show Edit Data SQL pane on startup'),
'type': 'object',
'properties': {
'editor.showEditDataSqlPaneOnStartup': {
'type': 'boolean',
'default': false,
'description': nls.localize('showEditDataSqlPaneOnStartup', 'Show Edit Data SQL pane on startup')
}
}
});
Registry.as<IEditorRegistry>(Extensions.Editors)
.registerEditor(editDataEditorDescriptor, [new SyncDescriptor(EditDataInput)]);
@@ -30,3 +49,17 @@ const editDataResultsEditorDescriptor = EditorDescriptor.create(
Registry.as<IEditorRegistry>(Extensions.Editors)
.registerEditor(editDataResultsEditorDescriptor, [new SyncDescriptor(EditDataResultsInput)]);
// Keybinding for toggling the query pane
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: editDataActions.ShowQueryPaneAction.ID,
weight: KeybindingWeight.EditorContrib,
when: undefined,
primary: undefined,
handler: accessor => {
const activeEditDataEditor = accessor.get(IEditorService).activeEditorPane;
if (activeEditDataEditor instanceof EditDataEditor) {
activeEditDataEditor.runShowQueryPane();
}
}
});

View File

@@ -680,6 +680,13 @@ export class EditDataEditor extends BaseEditor {
}
}
/**
* Calls the run method of this editor's showQueryPaneAction
*/
public runShowQueryPane(): void {
this._showQueryPaneAction.run();
}
/**
* Calls the run method of this editor's RunQueryAction
*/

View File

@@ -62,7 +62,6 @@ export class QueryEditorService implements IQueryEditorService {
const queryResultsInput: QueryResultsInput = this._instantiationService.createInstance(QueryResultsInput, docUri.toString());
let queryInput = this._instantiationService.createInstance(UntitledQueryEditorInput, options.description, fileInput, queryResultsInput);
if (options.open) {
await this._editorService.openEditor(queryInput, { pinned: true });
}
@@ -88,6 +87,8 @@ export class QueryEditorService implements IQueryEditorService {
// Create an EditDataInput for editing
const resultsInput: EditDataResultsInput = this._instantiationService.createInstance(EditDataResultsInput, docUri.toString());
let editDataInput: EditDataInput = this._instantiationService.createInstance(EditDataInput, docUri, schemaName, tableName, fileInput, sqlContent, resultsInput);
// Determine whether to show edit data upon opening.
editDataInput.queryPaneEnabled = this._configurationService.getValue('editor.showEditDataSqlPaneOnStartup');
if (sqlContent) {
//Setting the value of the textEditorModel to sqlContent marks editor as dirty, editDataInput handles it.
m.textEditorModel.setValue(sqlContent);