Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what exactly undoStopAfter and undoStopBefore options in edit method mean how do they behave

edit method on TextEditor of Vs Code Api

e.edit((editBuilder) =>{//here e is an object of texteditor 
            editBuilder.insert(_p, content);
            return true;
        },
        {undoStopAfter : true ,undoStopBefore : false}
    ).then(x=>{
       // what will happen after specifying undoStopAfter and undoStopBefore options?
            return true;
        });
like image 615
Adi Avatar asked Dec 31 '25 10:12

Adi


1 Answers

They specify if an "undo stop" should be inserted before and after the document change (in this case an edit) is executed. An "undo stop" is like a checkpoint you access when using ctrl+z/ctrl+y. If both are set to false, then the edit will practically be part of the previous edit in the otherwise inaccessible history stack that vscode uses.

See my question and answer here for an example of a use-case.

By default it seems like edit adds an "undo stop" before an edit (undoStopAfter : true), but it is ambiguous if it adds one after an edit.

like image 88
Zoom Avatar answered Jan 06 '26 00:01

Zoom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!