Skip to content
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

Support controlling whether edits are pre-ticked in WorkspaceEdits with needsConfirmation=true #207578

Open
DanTup opened this issue Mar 13, 2024 · 5 comments · May be fixed by #210175
Open

Support controlling whether edits are pre-ticked in WorkspaceEdits with needsConfirmation=true #207578

DanTup opened this issue Mar 13, 2024 · 5 comments · May be fixed by #210175
Assignees
Labels
feature-request Request for new features or functionality ux User experience issues workspace-edit
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented Mar 13, 2024

It's sometimes useful to force the user to review a preview of refactor changes before applying. This can be done with needsConfirmation:

const edit = new vscode.WorkspaceEdit();
const doc = await vscode.workspace.openTextDocument({ language: "text", content: "" });
edit.insert(doc.uri, new vscode.Position(0, 0), "This is inserted text", {
	label: "Insert imports",
	needsConfirmation: true, // Show preview, but also requires ticking
});
edit.insert(doc.uri, new vscode.Position(0, 0), "This is inserted text", {
	label: "Update code",
	needsConfirmation: true, // Show preview, but also requires ticking
});
vscode.workspace.applyEdit(edit);

image

However, the user needs to tick each change (at least the unique labels, which have a "Toggle Change" option on the context menu) which can be a pain if the edit is making a lot of changes that are grouped (for example fixing lint failures across a workspace, with each lint being a group).

It would be a much nicer experience if we could trigger the preview, but with everything ticked by default. In many cases we know the user is likely to apply all of the changes, but we still want to trigger a preview to be shown.

@jasonwang82
Copy link

It is a good suggestion, and we have the same thoughts of feedback. Or, is it possible vscode can add a button by default, saying select all/unselect all

@jrieken jrieken added feature-request Request for new features or functionality ux User experience issues workspace-edit labels Apr 8, 2024
@VSCodeTriageBot VSCodeTriageBot added this to the Backlog Candidates milestone Apr 8, 2024
@VSCodeTriageBot
Copy link
Collaborator

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@DanTup
Copy link
Contributor Author

DanTup commented Apr 10, 2024

@jrieken would you accept a PR to add something here?

For example an additional flag needsPreview that triggers the preview without being unticked?

Refactor previews that don't use commands are all ticked by default, so not being able to do it here leads to inconsistent refactors depending on whether they are CodeActions or triggered from commands.

@VSCodeTriageBot
Copy link
Collaborator

🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@DanTup
Copy link
Contributor Author

DanTup commented Apr 11, 2024

Started on a PR at #210175, feedback appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality ux User experience issues workspace-edit
Projects
None yet
4 participants