mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode a4177f50c475fc0fa278a78235e3bee9ffdec781 (#8649)
* Merge from vscode a4177f50c475fc0fa278a78235e3bee9ffdec781 * distro * fix tests
This commit is contained in:
@@ -290,6 +290,15 @@ export const enum SaveReason {
|
||||
WINDOW_CHANGE = 4
|
||||
}
|
||||
|
||||
export const enum SaveContext {
|
||||
|
||||
/**
|
||||
* Indicates that the editor is saved because it
|
||||
* is being closed by the user.
|
||||
*/
|
||||
EDITOR_CLOSE = 1,
|
||||
}
|
||||
|
||||
export interface ISaveOptions {
|
||||
|
||||
/**
|
||||
@@ -297,6 +306,11 @@ export interface ISaveOptions {
|
||||
*/
|
||||
reason?: SaveReason;
|
||||
|
||||
/**
|
||||
* Additional information about the context of the save.
|
||||
*/
|
||||
context?: SaveContext;
|
||||
|
||||
/**
|
||||
* Forces to load the contents of the working copy
|
||||
* again even if the working copy is not dirty.
|
||||
@@ -398,11 +412,6 @@ export interface IEditorInput extends IDisposable {
|
||||
*/
|
||||
saveAs(groupId: GroupIdentifier, options?: ISaveOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Handles when the input is replaced, such as by renaming its backing resource.
|
||||
*/
|
||||
handleMove?(groupId: GroupIdentifier, uri: URI, options?: ITextEditorOptions): IEditorInput | undefined;
|
||||
|
||||
/**
|
||||
* Reverts this input.
|
||||
*/
|
||||
@@ -553,10 +562,10 @@ export abstract class TextEditorInput extends EditorInput {
|
||||
}
|
||||
|
||||
saveAs(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise<boolean> {
|
||||
return this.doSaveAs(group, () => this.textFileService.saveAs(this.resource, undefined, options));
|
||||
return this.doSaveAs(group, options, () => this.textFileService.saveAs(this.resource, undefined, options));
|
||||
}
|
||||
|
||||
protected async doSaveAs(group: GroupIdentifier, saveRunnable: () => Promise<URI | undefined>, replaceAllEditors?: boolean): Promise<boolean> {
|
||||
protected async doSaveAs(group: GroupIdentifier, options: ISaveOptions | undefined, saveRunnable: () => Promise<URI | undefined>, replaceAllEditors?: boolean): Promise<boolean> {
|
||||
|
||||
// Preserve view state by opening the editor first. In addition
|
||||
// this allows the user to review the contents of the editor.
|
||||
@@ -574,7 +583,9 @@ export abstract class TextEditorInput extends EditorInput {
|
||||
|
||||
// Replace editor preserving viewstate (either across all groups or
|
||||
// only selected group) if the target is different from the current resource
|
||||
if (!isEqual(target, this.resource)) {
|
||||
// and if the editor is not being saved because it is being closed
|
||||
// (because in that case we do not want to open a different editor anyway)
|
||||
if (options?.context !== SaveContext.EDITOR_CLOSE && !isEqual(target, this.resource)) {
|
||||
const replacement = this.editorService.createInput({ resource: target });
|
||||
const targetGroups = replaceAllEditors ? this.editorGroupService.groups.map(group => group.id) : [group];
|
||||
for (const group of targetGroups) {
|
||||
|
||||
@@ -483,13 +483,12 @@ export class EditorGroup extends Disposable {
|
||||
private splice(index: number, del: boolean, editor?: EditorInput): void {
|
||||
const editorToDeleteOrReplace = this.editors[index];
|
||||
|
||||
const args: (number | EditorInput)[] = [index, del ? 1 : 0];
|
||||
if (editor) {
|
||||
args.push(editor);
|
||||
}
|
||||
|
||||
// Perform on editors array
|
||||
this.editors.splice.apply(this.editors, args);
|
||||
if (editor) {
|
||||
this.editors.splice(index, del ? 1 : 0, editor);
|
||||
} else {
|
||||
this.editors.splice(index, del ? 1 : 0);
|
||||
}
|
||||
|
||||
// Add
|
||||
if (!del && editor) {
|
||||
|
||||
@@ -163,7 +163,7 @@ export class UntitledTextEditorInput extends TextEditorInput implements IEncodin
|
||||
}
|
||||
|
||||
save(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise<boolean> {
|
||||
return this.doSaveAs(group, async () => {
|
||||
return this.doSaveAs(group, options, async () => {
|
||||
|
||||
// With associated file path, save to the path that is
|
||||
// associated. Make sure to convert the result using
|
||||
@@ -182,7 +182,7 @@ export class UntitledTextEditorInput extends TextEditorInput implements IEncodin
|
||||
}
|
||||
|
||||
saveAs(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise<boolean> {
|
||||
return this.doSaveAs(group, () => this.textFileService.saveAs(this.resource, undefined, options), true /* replace editor across all groups */);
|
||||
return this.doSaveAs(group, options, () => this.textFileService.saveAs(this.resource, undefined, options), true /* replace editor across all groups */);
|
||||
}
|
||||
|
||||
async revert(options?: IRevertOptions): Promise<boolean> {
|
||||
|
||||
14
src/vs/workbench/common/panecomposite.ts
Normal file
14
src/vs/workbench/common/panecomposite.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IView } from 'vs/workbench/common/views';
|
||||
import { IComposite } from 'vs/workbench/common/composite';
|
||||
import { IViewPaneContainer } from 'vs/workbench/common/viewPaneContainer';
|
||||
|
||||
export interface IPaneComposite extends IComposite {
|
||||
openView(id: string, focus?: boolean): IView;
|
||||
getViewPaneContainer(): IViewPaneContainer;
|
||||
saveState(): void;
|
||||
}
|
||||
16
src/vs/workbench/common/viewPaneContainer.ts
Normal file
16
src/vs/workbench/common/viewPaneContainer.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IAction, IActionViewItem } from 'vs/base/common/actions';
|
||||
|
||||
export interface IViewPaneContainer {
|
||||
setVisible(visible: boolean): void;
|
||||
isVisible(): boolean;
|
||||
focus(): void;
|
||||
getActions(): IAction[];
|
||||
getSecondaryActions(): IAction[];
|
||||
getActionViewItem(action: IAction): IActionViewItem | undefined;
|
||||
saveState(): void;
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IComposite } from 'vs/workbench/common/composite';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
|
||||
|
||||
export const SideBarVisibleContext = new RawContextKey<boolean>('sideBarVisible', false);
|
||||
export const SidebarFocusContext = new RawContextKey<boolean>('sideBarFocus', false);
|
||||
export const ActiveViewletContext = new RawContextKey<string>('activeViewlet', '');
|
||||
|
||||
export interface IViewlet extends IComposite {
|
||||
export interface IViewlet extends IPaneComposite {
|
||||
|
||||
/**
|
||||
* Returns the minimal width needed to avoid any content horizontal truncation
|
||||
|
||||
Reference in New Issue
Block a user