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