diff --git a/src/source_base.cpp b/src/source_base.cpp index 0504006..cf37573 100644 --- a/src/source_base.cpp +++ b/src/source_base.cpp @@ -1161,6 +1161,7 @@ void Source::BaseView::setup_extra_cursor_signals() { extra_cursor.offset = extra_cursor_iter.get_line_offset(); } for(auto &extra_cursor : extra_snippet_cursors) { + extra_cursor.initial_forward_erase_size = std::numeric_limits::max(); auto iter = extra_cursor.mark->get_iter(); iter.forward_chars(offset); get_buffer()->insert(iter, text); @@ -1194,15 +1195,13 @@ void Source::BaseView::setup_extra_cursor_signals() { for(auto &extra_cursor : extra_snippet_cursors) { auto start_iter = extra_cursor.mark->get_iter(); auto end_iter = start_iter; - if(extra_cursor.parameter_size != std::numeric_limits::max()) { // In case of different sized placeholders - if(*erase_backward_length == 0) - end_iter.forward_chars(extra_cursor.parameter_size); - extra_cursor.parameter_size = std::numeric_limits::max(); + start_iter.backward_chars(*erase_backward_length); + if(extra_cursor.initial_forward_erase_size != std::numeric_limits::max()) { // In case of different sized placeholders + end_iter.forward_chars(extra_cursor.initial_forward_erase_size); + extra_cursor.initial_forward_erase_size = std::numeric_limits::max(); } - else { - start_iter.backward_chars(*erase_backward_length); + else end_iter.forward_chars(*erase_forward_length); - } get_buffer()->erase(start_iter, end_iter); } enable_multiple_cursors = true; diff --git a/src/source_base.hpp b/src/source_base.hpp index 3633893..ed3f217 100644 --- a/src/source_base.hpp +++ b/src/source_base.hpp @@ -148,7 +148,7 @@ namespace Source { std::vector extra_cursors; struct ExtraSnippetCursor { Glib::RefPtr mark; - int parameter_size; + int initial_forward_erase_size; }; bool on_key_press_event_extra_cursors(GdkEventKey *key);