Another small structured binding conversion
This commit is contained in:
parent
e365c42b4b
commit
e06e409dc1
|
@ -221,36 +221,36 @@ void Buffer::reload(BufferLines lines, ByteOrderMark bom, EolFormat eolformat, F
|
||||||
|
|
||||||
auto it = m_lines.begin();
|
auto it = m_lines.begin();
|
||||||
auto new_it = lines.begin();
|
auto new_it = lines.begin();
|
||||||
for (auto& d : diff)
|
for (auto& [op, len] : diff)
|
||||||
{
|
{
|
||||||
if (d.op == DiffOp::Keep)
|
if (op == DiffOp::Keep)
|
||||||
{
|
{
|
||||||
it += d.len;
|
it += len;
|
||||||
new_it += d.len;
|
new_it += len;
|
||||||
}
|
}
|
||||||
else if (d.op == DiffOp::Add)
|
else if (op == DiffOp::Add)
|
||||||
{
|
{
|
||||||
const LineCount cur_line = (int)(it - m_lines.begin());
|
const LineCount cur_line = (int)(it - m_lines.begin());
|
||||||
|
|
||||||
for (LineCount line = 0; line < d.len; ++line)
|
for (LineCount line = 0; line < len; ++line)
|
||||||
m_current_undo_group.push_back({Modification::Insert, cur_line + line, *(new_it + (int)line)});
|
m_current_undo_group.push_back({Modification::Insert, cur_line + line, *(new_it + (int)line)});
|
||||||
|
|
||||||
m_changes.push_back({Change::Insert, cur_line, cur_line + d.len});
|
m_changes.push_back({Change::Insert, cur_line, cur_line + len});
|
||||||
m_lines.insert(it, new_it, new_it + d.len);
|
m_lines.insert(it, new_it, new_it + len);
|
||||||
it = m_lines.begin() + (int)(cur_line + d.len);
|
it = m_lines.begin() + (int)(cur_line + len);
|
||||||
new_it += d.len;
|
new_it += len;
|
||||||
}
|
}
|
||||||
else if (d.op == DiffOp::Remove)
|
else if (op == DiffOp::Remove)
|
||||||
{
|
{
|
||||||
const LineCount cur_line = (int)(it - m_lines.begin());
|
const LineCount cur_line = (int)(it - m_lines.begin());
|
||||||
|
|
||||||
for (LineCount line = d.len-1; line >= 0; --line)
|
for (LineCount line = len-1; line >= 0; --line)
|
||||||
m_current_undo_group.push_back({
|
m_current_undo_group.push_back({
|
||||||
Modification::Erase, cur_line + line,
|
Modification::Erase, cur_line + line,
|
||||||
m_lines.get_storage(cur_line + line)});
|
m_lines.get_storage(cur_line + line)});
|
||||||
|
|
||||||
it = m_lines.erase(it, it + d.len);
|
it = m_lines.erase(it, it + len);
|
||||||
m_changes.push_back({ Change::Erase, cur_line, cur_line + d.len });
|
m_changes.push_back({ Change::Erase, cur_line, cur_line + len });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user