Use existing resource for untitled if it is already open (#11536)

* use existing resource for untitled if it is already open

* remove unnecessary call
This commit is contained in:
Anthony Dresser
2020-07-28 13:09:51 -07:00
committed by GitHub
parent ada8cb2f08
commit d244a14468
4 changed files with 30 additions and 4 deletions

View File

@@ -48,8 +48,7 @@ export class QueryEditorService implements IQueryEditorService {
public async newSqlEditor(options: INewSqlEditorOptions = {}): Promise<IConnectableInput> {
options = mixin(options, defaults, false);
// Create file path and file URI
let filePath = await this.createUntitledSqlFilePath();
let docUri: URI = URI.from({ scheme: Schemas.untitled, path: filePath });
let docUri: URI = options.resource ?? URI.from({ scheme: Schemas.untitled, path: await this.createUntitledSqlFilePath() });
// Create a sql document pane with accoutrements
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: 'sql' }) as UntitledTextEditorInput;

View File

@@ -6,6 +6,7 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IConnectableInput } from 'sql/platform/connection/common/connectionManagement';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { URI } from 'vs/base/common/uri';
export interface IQueryEditorOptions extends IEditorOptions {
@@ -27,6 +28,10 @@ export interface INewSqlEditorOptions {
* defaults to true
*/
open?: boolean;
/**
* use an existing resource, if this matches a resource already open that resource will be opened instead
*/
resource?: URI
}
export interface IQueryEditorService {