Fix issue where undoing the second-to-first vertex of a way when drawing would undo to the initial state of the way (close #7772)

This commit is contained in:
Quincy Morgan
2020-09-02 11:07:09 -04:00
parent 5ae62e1803
commit a1987e21d9

View File

@@ -195,23 +195,23 @@ export function behaviorDrawWay(context, wayID, mode, startGraph) {
var nextMode;
if (context.graph() === startGraph) { // we've undone back to the beginning
if (context.graph() === startGraph) {
// We've undone back to the initial state before we started drawing.
// Just exit the draw mode without undoing whatever we did before
// we entered the draw mode.
nextMode = modeSelect(context, [wayID]);
} else {
context.history()
.on('undone.draw', null);
// remove whatever segment was drawn previously
context.undo();
// The `undo` only removed the temporary edit, so here we have to
// manually undo to actually remove the last node we added. We can't
// use the `undo` function since the initial "add" graph doesn't have
// an annotation and so cannot be undone to.
context.pop(1);
if (context.graph() === startGraph) { // we've undone back to the beginning
nextMode = modeSelect(context, [wayID]);
} else {
// continue drawing
nextMode = mode;
}
// continue drawing
nextMode = mode;
}
// clear the redo stack by adding and removing an edit
// clear the redo stack by adding and removing a blank edit
context.perform(actionNoop());
context.pop(1);