Skip to content

Commit

Permalink
Keybinding for Show SQL Pane (microsoft#9750)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
smartguest authored May 14, 2020
1 parent e3218ad commit 8f7861d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)]);

Expand All @@ -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();
}
}
});
7 changes: 7 additions & 0 deletions src/sql/workbench/contrib/editData/browser/editDataEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand All @@ -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);
Expand Down

0 comments on commit 8f7861d

Please sign in to comment.