mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 11:08:31 -05:00
fix the save and save all for untitled file (#2526)
This commit is contained in:
@@ -40,7 +40,7 @@ import { getMultiSelectedEditorContexts } from 'vs/workbench/browser/parts/edito
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorService, SIDE_GROUP, IResourceEditorReplacement } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { isEqual, basenameOrAuthority } from 'vs/base/common/resources';
|
||||
import { ltrim } from 'vs/base/common/strings';
|
||||
@@ -165,7 +165,7 @@ function save(
|
||||
// {{SQL CARBON EDIT}}
|
||||
queryEditorService.onSaveAsCompleted(resource, target);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -215,14 +215,27 @@ function saveAll(saveAllArguments: any, editorService: IEditorService, untitledE
|
||||
// Save all
|
||||
return textFileService.saveAll(saveAllArguments).then((result) => {
|
||||
groupIdToUntitledResourceInput.forEach((inputs, groupId) => {
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Update untitled resources to the saved ones, so we open the proper files
|
||||
|
||||
let replacementPairs: IResourceEditorReplacement[] = [];
|
||||
inputs.forEach(i => {
|
||||
const targetResult = result.results.filter(r => r.success && r.source.toString() === i.resource.toString()).pop();
|
||||
if (targetResult) {
|
||||
i.resource = targetResult.target;
|
||||
//i.resource = targetResult.target;
|
||||
let editor = i;
|
||||
const replacement: IResourceInput = {
|
||||
resource: targetResult.target,
|
||||
encoding: i.encoding,
|
||||
options: {
|
||||
pinned: true,
|
||||
viewState: undefined
|
||||
}
|
||||
};
|
||||
replacementPairs.push({ editor: editor, replacement: replacement });
|
||||
}
|
||||
});
|
||||
editorService.openEditors(inputs, groupId);
|
||||
editorService.replaceEditors(replacementPairs, groupId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -233,18 +233,12 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
return this.doOpenEditor(targetGroup, editor, editorOptions);
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Untyped Text Editor Support
|
||||
const textInput = <IResourceEditor>editor;
|
||||
let typedInput = this.createInput(textInput);
|
||||
const typedInput = this.createInput(textInput);
|
||||
if (typedInput) {
|
||||
const editorOptions = TextEditorOptions.from(textInput);
|
||||
const targetGroup = this.findTargetGroup(typedInput, editorOptions, optionsOrGroup as IEditorGroup | GroupIdentifier);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// Convert input into custom type if it's one of the ones we support
|
||||
typedInput = convertEditorInput(typedInput, editorOptions, this.instantiationService);
|
||||
|
||||
return this.doOpenEditor(targetGroup, typedInput, editorOptions);
|
||||
}
|
||||
|
||||
@@ -501,12 +495,12 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
const untitledInput = <IUntitledResourceInput>input;
|
||||
if (!untitledInput.resource || typeof untitledInput.filePath === 'string' || (untitledInput.resource instanceof URI && untitledInput.resource.scheme === Schemas.untitled)) {
|
||||
// {{SQL CARBON EDIT}}
|
||||
return this.untitledEditorService.createOrGet(
|
||||
return convertEditorInput(this.untitledEditorService.createOrGet(
|
||||
untitledInput.filePath ? URI.file(untitledInput.filePath) : untitledInput.resource,
|
||||
'sql',
|
||||
untitledInput.contents,
|
||||
untitledInput.encoding
|
||||
);
|
||||
), undefined, this.instantiationService);
|
||||
}
|
||||
|
||||
// Resource Editor Support
|
||||
@@ -516,8 +510,9 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
if (!label && resourceInput.resource.scheme !== Schemas.data) {
|
||||
label = basename(resourceInput.resource.fsPath); // derive the label from the path (but not for data URIs)
|
||||
}
|
||||
|
||||
return this.createOrGet(resourceInput.resource, this.instantiationService, label, resourceInput.description, resourceInput.encoding, options && options.forceFileInput) as EditorInput;
|
||||
// {{SQL CARBON EDIT}}
|
||||
return convertEditorInput(this.createOrGet(resourceInput.resource, this.instantiationService, label, resourceInput.description, resourceInput.encoding, options && options.forceFileInput) as EditorInput,
|
||||
undefined, this.instantiationService);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user