diff --git a/application/editormode.h b/application/editormode.h index 4a4313acd..d3c79a408 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -54,6 +54,7 @@ http://mozilla.org/MPL/2.0/. #include "world/Sweep.h" #include +#include #include #include #include @@ -1141,6 +1142,8 @@ class editor_mode : public application_mode, private editor_track::observer, pri // false, with the reason, when one of the paths can't be changed, its file not taking the changes back static bool tracks_editable(std::vector const &Tracks, std::string &Reason); void trim_history(); + // the serial of the step on top of the history, 0 with none + std::uint64_t history_top() const; void restore_track_snapshot(EditorSnapshot const &Snapshot, std::vector &Opposite, bool const Undo); // changes of the kept alignments and switches go into the last step of the history, made just before them void records_to_history(); @@ -1920,9 +1923,10 @@ class editor_mode : public application_mode, private editor_track::observer, pri bool settings_open{false}; bool details_open{false}; bool notes_open{false}; - // the status tells of a line laid just now, as long as the history stays at the step it was laid with + // the status tells of a line laid just now, as long as the history stays at the step it was laid with: the serial of the step on + // top then, not the size of the history, which an undo and another step make the same again bool laid_now{false}; - std::size_t laid_step{0}; + std::uint64_t laid_step{0}; // the line laid last, told in the inspector while the last of its tracks stays the selection the laying left struct laid_curve { diff --git a/application/editormodelay.cpp b/application/editormodelay.cpp index 83f8896c6..0c3b215d2 100644 --- a/application/editormodelay.cpp +++ b/application/editormodelay.cpp @@ -2141,7 +2141,7 @@ void editor_mode::lay_finish(editor_track::snap_target const &End) tool.points.clear(); tool.modes.clear(); tool.start = {}; - tool.laid_step = m_history.size(); + tool.laid_step = history_top(); straight_refresh(); } @@ -2152,7 +2152,7 @@ void editor_mode::lay_told(double const Length, std::size_t const Tracks) tool.status_time = ImGui::GetTime(); tool.laid_now = true; tool.notes_open = false; - tool.laid_step = m_history.size(); + tool.laid_step = history_top(); } void editor_mode::lay_enter() @@ -2352,13 +2352,18 @@ alignment::limits editor_mode::laying_norms() const return norms; } +std::uint64_t editor_mode::history_top() const +{ + return m_history.empty() ? 0 : m_history.back().serial; +} + editor_mode::lay_state editor_mode::lay_panel_state() const { if (m_extend.active) return lay_state::extending; if (false == m_lay.points.empty()) return lay_state::clicking; - if (m_lay.laid_now && m_lay.laid_step == m_history.size()) + if (m_lay.laid_now && m_lay.laid_step == history_top()) return lay_state::laid; return lay_state::ready; }