mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Fix opening new untitled query (#16078)
This commit is contained in:
@@ -24,6 +24,7 @@ import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities'
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
const defaults: INewSqlEditorOptions = {
|
||||
open: true
|
||||
};
|
||||
@@ -50,7 +51,7 @@ export class QueryEditorService implements IQueryEditorService {
|
||||
/**
|
||||
* Creates new untitled document for SQL/Kusto query and opens in new editor tab
|
||||
*/
|
||||
public async newSqlEditor(options: INewSqlEditorOptions = {}, connectionProviderName?: string): Promise<IConnectableInput> {
|
||||
public async newSqlEditor(options: INewSqlEditorOptions = {}, connectionProviderName?: string): Promise<UntitledQueryEditorInput> {
|
||||
options = mixin(options, defaults, false);
|
||||
// Create file path and file URI
|
||||
let docUri: URI = options.resource ?? URI.from({ scheme: Schemas.untitled, path: await this.createUntitledSqlFilePath(connectionProviderName) });
|
||||
|
||||
@@ -7,6 +7,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';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
|
||||
export interface IQueryEditorOptions extends IEditorOptions {
|
||||
|
||||
@@ -44,7 +45,7 @@ export interface IQueryEditorService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
// Creates new untitled document for SQL/KUSTO queries and opens it in a new editor tab
|
||||
newSqlEditor(options?: INewSqlEditorOptions, connectionProviderName?: string): Promise<IConnectableInput>;
|
||||
newSqlEditor(options?: INewSqlEditorOptions, connectionProviderName?: string): Promise<UntitledQueryEditorInput>;
|
||||
|
||||
// Creates new edit data session
|
||||
newEditDataEditor(schemaName: string, tableName: string, queryString: string): Promise<IConnectableInput>;
|
||||
|
||||
@@ -19,7 +19,7 @@ export class TestQueryEditorService implements IQueryEditorService {
|
||||
@IEditorService private readonly editorService: IEditorService) {
|
||||
}
|
||||
|
||||
newSqlEditor(options?: INewSqlEditorOptions): Promise<IConnectableInput> {
|
||||
newSqlEditor(options?: INewSqlEditorOptions): Promise<UntitledQueryEditorInput> {
|
||||
const base = this.editorService.createEditorInput({ forceUntitled: true }) as UntitledTextEditorInput;
|
||||
return Promise.resolve(this.instantiationService.createInstance(UntitledQueryEditorInput, '', base, new QueryResultsInput(base.resource.toString(true))));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { Promises, RunOnceWorker } from 'vs/base/common/async';
|
||||
import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch';
|
||||
import { TitleControl } from 'vs/workbench/browser/parts/editor/titleControl';
|
||||
import { IEditorGroupsAccessor, IEditorGroupView, getActiveTextEditorOptions, EditorServiceImpl, IEditorGroupTitleHeight } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { IEditorGroupsAccessor, IEditorGroupView, getActiveTextEditorOptions, IEditorGroupTitleHeight } from 'vs/workbench/browser/parts/editor/editor'; // {{SQL CARBON EDIT}} Remove unused
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ActionRunner, IAction, Action } from 'vs/base/common/actions';
|
||||
@@ -40,7 +40,7 @@ import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
// import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; {{SQL CARBON EDIT}} Remove unused
|
||||
import { hash } from 'vs/base/common/hash';
|
||||
import { guessMimeTypes } from 'vs/base/common/mime';
|
||||
import { extname, isEqual } from 'vs/base/common/resources';
|
||||
@@ -53,6 +53,7 @@ import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService'; // {{SQL CARBON EDIT}}
|
||||
|
||||
export class EditorGroupView extends Themable implements IEditorGroupView {
|
||||
|
||||
@@ -140,7 +141,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
||||
@IContextMenuService private readonly contextMenuService: IContextMenuService,
|
||||
@IFileDialogService private readonly fileDialogService: IFileDialogService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IEditorService private readonly editorService: EditorServiceImpl,
|
||||
@IQueryEditorService private readonly queryEditorService: IQueryEditorService, // {{SQL CARBON EDIT}} Use our own service
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
|
||||
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
|
||||
) {
|
||||
@@ -282,12 +283,12 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
||||
private registerContainerListeners(): void {
|
||||
|
||||
// Open new file via doubleclick on empty container
|
||||
this._register(addDisposableListener(this.element, EventType.DBLCLICK, e => {
|
||||
this._register(addDisposableListener(this.element, EventType.DBLCLICK, async (e) => {
|
||||
if (this.isEmpty) {
|
||||
EventHelper.stop(e);
|
||||
|
||||
// {{SQL CARBON EDIT}} - use editor service to open editor, which will go through the override step and resolve to UntitledQueryEditorInput.
|
||||
this.editorService.openEditor(this.editorService.createEditorInput({ forceUntitled: true }), EditorOptions.create({ pinned: true }));
|
||||
// {{SQL CARBON EDIT}} - Create our own editor input so we open an untitled query editor
|
||||
const queryEditorInput = await this.queryEditorService.newSqlEditor({ connectWithGlobal: true, open: false });
|
||||
this.openEditor(queryEditorInput, EditorOptions.create({ pinned: true }));
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { MergeGroupMode, IMergeGroupOptions, GroupsArrangement, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { addDisposableListener, EventType, EventHelper, Dimension, scheduleAtNextAnimationFrame, findParentWithClass, clearNode } from 'vs/base/browser/dom';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IEditorGroupsAccessor, IEditorGroupView, EditorServiceImpl, IEditorGroupTitleHeight } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { IEditorGroupsAccessor, IEditorGroupView, IEditorGroupTitleHeight } from 'vs/workbench/browser/parts/editor/editor'; // {{SQL CARBON EDIT}} Remove unused
|
||||
import { CloseOneEditorAction, UnpinEditorAction } from 'vs/workbench/browser/parts/editor/editorActions';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { BreadcrumbsControl } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { withNullAsUndefined, assertAllDefined, assertIsDefined } from 'vs/base/common/types';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
// import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; {{SQL CARBON EDIT}} Remove unused
|
||||
import { basenameOrAuthority } from 'vs/base/common/resources';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { IPathService } from 'vs/workbench/services/path/common/pathService';
|
||||
@@ -50,9 +50,8 @@ import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||
import { isSafari } from 'vs/base/browser/browser';
|
||||
import { equals } from 'vs/base/common/objects';
|
||||
|
||||
// {{SQL CARBON EDIT}} -- Display the editor's tab color
|
||||
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query';
|
||||
// {{SQL CARBON EDIT}} -- End
|
||||
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query'; // {{SQL CARBON EDIT}}
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService'; // {{SQL CARBON EDIT}}
|
||||
|
||||
interface IEditorInputLabel {
|
||||
name?: string;
|
||||
@@ -122,7 +121,7 @@ export class TabsTitleControl extends TitleControl {
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IEditorService private readonly editorService: EditorServiceImpl,
|
||||
@IQueryEditorService private readonly queryEditorService: IQueryEditorService, // {{SQL CARBON EDIT}}
|
||||
@IPathService private readonly pathService: IPathService,
|
||||
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
|
||||
) {
|
||||
@@ -220,7 +219,7 @@ export class TabsTitleControl extends TitleControl {
|
||||
|
||||
// New file when double clicking on tabs container (but not tabs)
|
||||
[TouchEventType.Tap, EventType.DBLCLICK].forEach(eventType => {
|
||||
this._register(addDisposableListener(tabsContainer, eventType, (e: MouseEvent | GestureEvent) => {
|
||||
this._register(addDisposableListener(tabsContainer, eventType, async (e: MouseEvent | GestureEvent) => {
|
||||
if (eventType === EventType.DBLCLICK) {
|
||||
if (e.target !== tabsContainer) {
|
||||
return; // ignore if target is not tabs container
|
||||
@@ -236,13 +235,15 @@ export class TabsTitleControl extends TitleControl {
|
||||
}
|
||||
|
||||
EventHelper.stop(e);
|
||||
// {{SQL CARBON EDIT}} - use editor service to open editor, which will go through the override step and resolve to UntitledQueryEditorInput.
|
||||
this.editorService.openEditor(
|
||||
this.editorService.createEditorInput({ forceUntitled: true }),
|
||||
// {{SQL CARBON EDIT}} - Create our own editor input so we open an untitled query editor
|
||||
const queryEditorInput = await this.queryEditorService.newSqlEditor({ connectWithGlobal: true, open: false });
|
||||
this.group.openEditor(
|
||||
queryEditorInput,
|
||||
{
|
||||
pinned: true, // untitled is always pinned
|
||||
index: this.group.count // always at the end
|
||||
}, this.group);
|
||||
}
|
||||
);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user