From 17951bf077109e9c283d8a160fbcf05932183075 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 11 Oct 2013 18:44:43 +0100 Subject: [PATCH] Fix Editor::remove_selection when the main selection is the first one and is the removed one --- src/editor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/editor.cc b/src/editor.cc index ae156041..225d5413 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -250,7 +250,8 @@ void Editor::remove_selection(int index) size_t real_index = (index + m_main_sel + 1) % m_selections.size(); m_selections.erase(m_selections.begin() + real_index); if (real_index <= m_main_sel) - --m_main_sel; + m_main_sel = (m_main_sel > 0 ? m_main_sel + : m_selections.size()) - 1; } check_invariant(); }