From 0f957b374338ca5eba3bf4e7667c79a29fc6a73a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 13 Mar 2013 14:26:20 +0100 Subject: Editor: fix replace at end of buffer --- src/unit_tests.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/unit_tests.cc') diff --git a/src/unit_tests.cc b/src/unit_tests.cc index a092fd5c..09ad7f4e 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -55,15 +55,22 @@ void test_editor() Buffer buffer("test", Buffer::Flags::None, { "test\n", "\n", "youpi\n" }); Editor editor(buffer); - using namespace std::placeholders; - - editor.select(select_whole_buffer); - editor.multi_select(std::bind(select_all_matches, _1, "\\n\\h*")); - for (auto& sel : editor.selections()) { - assert(*sel.begin() == '\n'); - editor.buffer().erase(sel.begin(), sel.end()); + scoped_edition edition{editor}; + editor.select(select_whole_buffer); + editor.multi_select(std::bind(select_all_matches, std::placeholders::_1, "\\n\\h*")); + for (auto& sel : editor.selections()) + { + assert(*sel.begin() == '\n'); + editor.buffer().erase(sel.begin(), sel.end()); + } } + editor.undo(); + + Selection sel{ buffer.iterator_at_line_begin(2_line), buffer.end() }; + editor.select(sel, SelectMode::Replace); + editor.insert("",InsertMode::Replace); + assert(not editor.selections().back().first().is_end()); } void test_incremental_inserter() -- cgit v1.2.3