summaryrefslogtreecommitdiff
path: root/src/buffer.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-12-18 11:36:17 +1100
committerMaxime Coste <mawww@kakoune.org>2019-12-18 11:36:17 +1100
commitb68490ef11734c404f8a18f1babd8004aca2de06 (patch)
tree82ffc4180aa05d440df4a4d79adb57871af3948b /src/buffer.hh
parentcbb7f601f665e77a7ee1b338e87a413738dba43f (diff)
Cleanup replaced range selection logic
Do not access Buffer::m_changes to find the inserted range, return it directly from Buffer::insert and Buffer::replace. This fixes a wrong behaviour where replacing at eof would lose the selected end of line (as the implementation does not actually replace that end of line)
Diffstat (limited to 'src/buffer.hh')
-rw-r--r--src/buffer.hh8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/buffer.hh b/src/buffer.hh
index 4f27e449..a2517956 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -7,6 +7,7 @@
#include "enum.hh"
#include "file.hh"
#include "optional.hh"
+#include "range.hh"
#include "safe_ptr.hh"
#include "scope.hh"
#include "shared_string.hh"
@@ -103,6 +104,7 @@ private:
};
using BufferLines = Vector<StringDataPtr, MemoryDomain::BufferContent>;
+using BufferRange = Range<BufferCoord>;
// A Buffer is a in-memory representation of a file
//
@@ -139,9 +141,9 @@ public:
bool set_name(String name);
void update_display_name();
- BufferCoord insert(BufferCoord pos, StringView content);
+ BufferRange insert(BufferCoord pos, StringView content);
BufferCoord erase(BufferCoord begin, BufferCoord end);
- BufferCoord replace(BufferCoord begin, BufferCoord end, StringView content);
+ BufferRange replace(BufferCoord begin, BufferCoord end, StringView content);
size_t timestamp() const;
void set_fs_status(FsStatus);
@@ -231,7 +233,7 @@ public:
private:
void on_option_changed(const Option& option) override;
- BufferCoord do_insert(BufferCoord pos, StringView content);
+ BufferRange do_insert(BufferCoord pos, StringView content);
BufferCoord do_erase(BufferCoord begin, BufferCoord end);
struct Modification;