Fix opening new untitled query (#16078)

This commit is contained in:
Charles Gagnon
2021-07-12 14:37:53 -07:00
committed by GitHub
parent 32ba55b7ed
commit 9fc2cff654
5 changed files with 25 additions and 21 deletions

View File

@@ -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 }));
}
}));

View File

@@ -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);
}
);
}));
});