@codemirror/history
Advanced tools
Comparing version 0.19.1 to 0.19.2
@@ -0,1 +1,7 @@ | ||
## 0.19.2 (2022-01-03) | ||
### Bug fixes | ||
Redoing a change now puts the cursor right after the change, regardless of where the selection was when the change was undone. | ||
## 0.19.1 (2021-12-28) | ||
@@ -2,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Annotation, Facet, combineConfig, StateField, Transaction, ChangeSet, ChangeDesc, EditorSelection, StateEffect } from '@codemirror/state'; | ||
import { Annotation, Facet, combineConfig, StateField, EditorSelection, Transaction, ChangeSet, ChangeDesc, StateEffect } from '@codemirror/state'; | ||
import { EditorView } from '@codemirror/view'; | ||
@@ -29,2 +29,7 @@ | ||
}); | ||
function changeEnd(changes) { | ||
let end = 0; | ||
changes.iterChangedRanges((_, to) => end = to); | ||
return end; | ||
} | ||
const historyField_ = /*@__PURE__*/StateField.define({ | ||
@@ -38,3 +43,4 @@ create() { | ||
if (fromHist) { | ||
let item = HistEvent.fromTransaction(tr), from = fromHist.side; | ||
let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined; | ||
let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side; | ||
let other = from == 0 /* Done */ ? state.undone : state.done; | ||
@@ -185,3 +191,3 @@ if (item) | ||
// there are no changes or effects in the transaction. | ||
static fromTransaction(tr) { | ||
static fromTransaction(tr, selection) { | ||
let effects = none; | ||
@@ -195,3 +201,3 @@ for (let invert of tr.startState.facet(invertedEffects)) { | ||
return null; | ||
return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, tr.startState.selection, none); | ||
return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none); | ||
} | ||
@@ -198,0 +204,0 @@ static selection(selections) { |
{ | ||
"name": "@codemirror/history", | ||
"version": "0.19.1", | ||
"version": "0.19.2", | ||
"description": "Undo/redo history for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
39297
822