Skip to content

Add optional "showPreview" to WorkspaceEditMetadata to allow forcing preview without needsConfirmation changes #210175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vs/workbench/api/browser/mainThreadBulkEdits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class MainThreadBulkEdits implements MainThreadBulkEditsShape {

dispose(): void { }

$tryApplyWorkspaceEdit(dto: SerializableObjectWithBuffers<IWorkspaceEditDto>, undoRedoGroupId?: number, isRefactoring?: boolean): Promise<boolean> {
$tryApplyWorkspaceEdit(dto: SerializableObjectWithBuffers<IWorkspaceEditDto>, undoRedoGroupId?: number, isRefactoring?: boolean, showPreview?: boolean): Promise<boolean> {
const edits = reviveWorkspaceEditDto(dto.value, this._uriIdentService);
return this._bulkEditService.apply(edits, { undoRedoGroupId, respectAutoSaveConfig: isRefactoring }).then((res) => res.isApplied, err => {
return this._bulkEditService.apply(edits, { undoRedoGroupId, respectAutoSaveConfig: isRefactoring, showPreview: showPreview }).then((res) => res.isApplied, err => {
this._logService.warn(`IGNORING workspace edit: ${err}`);
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export interface ITextDocumentShowOptions {
}

export interface MainThreadBulkEditsShape extends IDisposable {
$tryApplyWorkspaceEdit(workspaceEditDto: SerializableObjectWithBuffers<IWorkspaceEditDto>, undoRedoGroupId?: number, respectAutoSaveConfig?: boolean): Promise<boolean>;
$tryApplyWorkspaceEdit(workspaceEditDto: SerializableObjectWithBuffers<IWorkspaceEditDto>, undoRedoGroupId?: number, respectAutoSaveConfig?: boolean, showPreview?: boolean): Promise<boolean>;
}

export interface MainThreadTextEditorsShape extends IDisposable {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostBulkEdits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export class ExtHostBulkEdits {

applyWorkspaceEdit(edit: vscode.WorkspaceEdit, extension: IExtensionDescription, metadata: vscode.WorkspaceEditMetadata | undefined): Promise<boolean> {
const dto = new SerializableObjectWithBuffers(WorkspaceEdit.from(edit, this._versionInformationProvider));
return this._proxy.$tryApplyWorkspaceEdit(dto, undefined, metadata?.isRefactoring ?? false);
return this._proxy.$tryApplyWorkspaceEdit(dto, undefined, metadata?.isRefactoring ?? false, metadata?.showPreview);
}
}
5 changes: 5 additions & 0 deletions src/vscode-dts/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3896,6 +3896,11 @@ declare module 'vscode' {
* Signal to the editor that this edit is a refactoring.
*/
isRefactoring?: boolean;

/**
* Signal to the editor that a preview should be displayed, even if there are no edits to confirm.
*/
showPreview?: boolean;
}

/**
Expand Down