mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 17:23:35 -05:00
Query editor input titles (#9512)
* address untitled editor file name differences; remove feature for updating title for untitled to content * add tests for new methods * fix tests * fix up tests * remove unncessary await * revert changes to title for content
This commit is contained in:
@@ -20,8 +20,8 @@ export function doHandleUpgrade(editor?: EditorInput): EditorInput | undefined {
|
||||
editor.getPreferredMode();
|
||||
}
|
||||
const association = languageRegistry.getAssociationForLanguage(language);
|
||||
if (association) {
|
||||
return association.convertInput(editor);
|
||||
if (association && association.syncConvertinput) {
|
||||
return association.syncConvertinput(editor);
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
|
||||
@@ -12,7 +12,12 @@ export type InputCreator = (servicesAccessor: ServicesAccessor, activeEditor: IE
|
||||
export type BaseInputCreator = (activeEditor: IEditorInput) => IEditorInput;
|
||||
|
||||
export interface ILanguageAssociation {
|
||||
convertInput(activeEditor: IEditorInput): EditorInput | undefined;
|
||||
convertInput(activeEditor: IEditorInput): Promise<EditorInput | undefined> | EditorInput | undefined;
|
||||
/**
|
||||
* Used for scenarios when we need to synchrounly create inputs, currently only for handling upgrades
|
||||
* and planned to be removed eventually
|
||||
*/
|
||||
syncConvertinput?(activeEditor: IEditorInput): EditorInput | undefined;
|
||||
createBase(activeEditor: IEditorInput): IEditorInput;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { IConnectableInput } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
export class TestQueryEditorService implements IQueryEditorService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IEditorService private readonly editorService: IEditorService) {
|
||||
|
||||
}
|
||||
|
||||
newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean, objectName?: string): Promise<IConnectableInput> {
|
||||
const base = this.editorService.createInput({ forceUntitled: true }) as UntitledTextEditorInput;
|
||||
return Promise.resolve(this.instantiationService.createInstance(UntitledQueryEditorInput, '', base, new QueryResultsInput(base.resource.toString(true))));
|
||||
}
|
||||
|
||||
newEditDataEditor(schemaName: string, tableName: string, queryString: string): Promise<IConnectableInput> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user