vscode ``` Workspace edit metadata needsConfirmation results in all checkboxes unchecked ```

bz4sfanl  于 2个月前  发布在  Vscode
关注(0)|答案(1)|浏览(44)

The WorkspaceEdit that has metadata with needsConfirmation set to true shows the Refactor Preview which is great but all checkboxes are unchecked. I'd rather have all checkboxes checked.
I went through various git issues where showing Refactor View was first implemented. All screenshots show all changes check-marked. I also saw this one #144893 which also shows all changes check-marked and the request to check/uncheck a group of changes which would be useful.
However, I always have all changes unchecked and wonder how they could be all checked by default?
I'd appreciate a code snippet
For example i have this:

const edit: VSCode.WorkspaceEdit = new VSCode.WorkspaceEdit();
    
            const folders = VSCode.workspace.workspaceFolders;
            if (!folders || folders.length === 0) {
                VSCode.window.showInformationMessage('Open a folder first');
                return;
            }
            const newFile = VSCode.Uri.joinPath(folders[0].uri, 'foo.txt');
            edit.createFile(newFile, 
                { overwrite: true }, 
                { label: 'New text', needsConfirmation: true }
            );
    
            const initialContent = new TextEdit(new Range(new Position(0,0), new Position(0, 0)), "Hello World\nOne more line");
            edit.set(newFile, [initialContent]);
    
            VSCode.workspace.applyEdit(edit, { isRefactoring: true });

How can i make checkboxes checked for the above?

相关问题