summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-06-05 19:20:21 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-06-06 19:44:07 +0200
commit58ff97d51dba90e1d8fd783b003768d0e7259083 (patch)
tree3fff0a53b64f91d0daa44ac759feb56651c94a5c /src/normal.cc
parent43ff1909fbc242499ce9b529a34e7ade02c3b338 (diff)
use_selection_as_search_pattern: use iterators instead of coords
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 652a193e..a0fba585 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -15,6 +15,7 @@
#include "string.hh"
#include "window.hh"
#include "user_interface.hh"
+#include "utf8_iterator.hh"
namespace Kakoune
{
@@ -335,18 +336,14 @@ void use_selection_as_search_pattern(Context& context)
const auto& buffer = context.buffer();
for (auto& sel : sels)
{
- auto begin = sel.min();
- auto end = buffer.char_next(sel.max());
- auto content = "\\Q" + context.buffer().string(begin, end) + "\\E";
+ auto begin = utf8::make_iterator(buffer.iterator_at(sel.min()));
+ auto end = utf8::make_iterator(buffer.iterator_at(sel.max()))+1;
+ auto content = "\\Q" + String{begin.base(), end.base()} + "\\E";
if (smart)
{
- if (begin == BufferCoord{0,0} or
- (is_word(buffer.char_at(begin)) and not
- is_word(buffer.char_at(buffer.char_prev(begin)))))
+ if (begin == buffer.begin() or (is_word(*begin) and not is_word(*begin-1)))
content = "\\b" + content;
- if (buffer.is_end(end) or
- (is_word(buffer.char_at(buffer.char_prev(end))) and not
- is_word(buffer.char_at(end))))
+ if (end == buffer.end() or (is_word(*(end-1)) and not is_word(*end)))
content = content + "\\b";
}
patterns.push_back(std::move(content));