Fix selection update in when doing a 'replace' insert
This commit is contained in:
parent
eba98ecad4
commit
1544a006c9
|
@ -17,6 +17,7 @@
|
||||||
#include "user_interface.hh"
|
#include "user_interface.hh"
|
||||||
#include "utf8_iterator.hh"
|
#include "utf8_iterator.hh"
|
||||||
#include "debug.hh"
|
#include "debug.hh"
|
||||||
|
#include "modification.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
@ -67,6 +68,8 @@ void insert(Buffer& buffer, SelectionList& selections, memoryview<String> string
|
||||||
{
|
{
|
||||||
if (strings.empty())
|
if (strings.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
selections.update();
|
||||||
for (size_t i = 0; i < selections.size(); ++i)
|
for (size_t i = 0; i < selections.size(); ++i)
|
||||||
{
|
{
|
||||||
size_t index = selections.size() - 1 - i;
|
size_t index = selections.size() - 1 - i;
|
||||||
|
@ -78,10 +81,19 @@ void insert(Buffer& buffer, SelectionList& selections, memoryview<String> string
|
||||||
{
|
{
|
||||||
if (pos == buffer.end())
|
if (pos == buffer.end())
|
||||||
--pos;
|
--pos;
|
||||||
selections.update();
|
|
||||||
sel.anchor() = pos.coord();
|
sel.anchor() = pos.coord();
|
||||||
sel.cursor() = (str.empty() ?
|
sel.cursor() = (str.empty() ?
|
||||||
pos : pos + str.byte_count_to(str.char_length() - 1)).coord();
|
pos : pos + str.byte_count_to(str.char_length() - 1)).coord();
|
||||||
|
|
||||||
|
// update following selections
|
||||||
|
auto changes = compute_modifications(buffer, selections.timestamp());
|
||||||
|
for (size_t j = index+1; j < selections.size(); ++j)
|
||||||
|
{
|
||||||
|
auto& sel = selections[j];
|
||||||
|
sel.anchor() = update_pos(changes, sel.anchor());
|
||||||
|
sel.cursor() = update_pos(changes, sel.cursor());
|
||||||
|
}
|
||||||
|
selections.update_timestamp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selections.update();
|
selections.update();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user