File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1278,14 +1278,26 @@ declare module 'vscode' {
12781278 /**
12791279 * Undo a set of edits.
12801280 *
1281- * This is triggered when a user undoes an edit or when revert is called on a file .
1281+ * This is triggered when a user undoes an edit.
12821282 *
12831283 * @param edit Array of edits. Sorted from most recent to oldest.
12841284 *
12851285 * @return Thenable signaling that the change has completed.
12861286 */
12871287 undoEdits ( edits : readonly EditType [ ] ) : Thenable < void > ;
12881288
1289+ /**
1290+ * Revert the file to its last saved state.
1291+ *
1292+ * @param change Added or applied edits.
1293+ *
1294+ * @return Thenable signaling that the change has completed.
1295+ */
1296+ revert ( change : {
1297+ readonly undoneEdits : readonly EditType [ ] ;
1298+ readonly appliedEdits : readonly EditType [ ] ;
1299+ } ) : Thenable < void > ;
1300+
12891301 /**
12901302 * Back up the resource in its current state.
12911303 *
Original file line number Diff line number Diff line change @@ -303,23 +303,26 @@ class CustomDocument extends Disposable implements vscode.CustomDocument {
303303 } ) ;
304304 }
305305
306- /** @internal */ _revert ( ) {
306+ /** @internal */ async _revert ( ) {
307307 const editing = this . getEditingCapability ( ) ;
308308 if ( this . #currentEditIndex === this . #savePoint) {
309309 return true ;
310310 }
311311
312+
313+ let undoneEdits : EditType [ ] = [ ] ;
314+ let appliedEdits : EditType [ ] = [ ] ;
312315 if ( this . #currentEditIndex >= this . #savePoint) {
313- const editsToUndo = this . #edits. slice ( this . #savePoint, this . #currentEditIndex) ;
314- editing . undoEdits ( editsToUndo . reverse ( ) ) ;
316+ undoneEdits = this . #edits. slice ( this . #savePoint, this . #currentEditIndex) . reverse ( ) ;
315317 } else if ( this . #currentEditIndex < this . #savePoint) {
316- const editsToRedo = this . #edits. slice ( this . #currentEditIndex, this . #savePoint) ;
317- editing . applyEdits ( editsToRedo ) ;
318+ appliedEdits = this . #edits. slice ( this . #currentEditIndex, this . #savePoint) ;
318319 }
319320
320321 this . #currentEditIndex = this . #savePoint;
321322 this . spliceEdits ( ) ;
322323
324+ await editing . revert ( { undoneEdits, appliedEdits } ) ;
325+
323326 this . updateState ( ) ;
324327 return true ;
325328 }
You can’t perform that action at this time.
0 commit comments