Change x behaviour to select full line first even if on EOL
x will always first select current line fully, and only then select next line.
This commit is contained in:
parent
f907e6cc46
commit
28716ec058
|
@ -173,17 +173,13 @@ Optional<Selection>
|
||||||
select_line(const Context& context, const Selection& selection)
|
select_line(const Context& context, const Selection& selection)
|
||||||
{
|
{
|
||||||
auto& buffer = context.buffer();
|
auto& buffer = context.buffer();
|
||||||
Utf8Iterator first{buffer.iterator_at(selection.cursor()), buffer};
|
auto line = selection.cursor().line;
|
||||||
if (*first == '\n' and first + 1 != buffer.end())
|
// Next line if line fully selected
|
||||||
++first;
|
if (selection.anchor() <= BufferCoord{line, 0_byte} and
|
||||||
|
selection.cursor() == BufferCoord{line, buffer[line].length() - 1} and
|
||||||
while (first != buffer.begin() and *(first - 1) != '\n')
|
line != buffer.line_count() - 1)
|
||||||
--first;
|
++line;
|
||||||
|
return target_eol({{line, 0_byte}, {line, buffer[line].length() - 1}});
|
||||||
Utf8Iterator last = first;
|
|
||||||
while (last + 1 != buffer.end() and *last != '\n')
|
|
||||||
++last;
|
|
||||||
return target_eol(utf8_range(first, last));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool only_move>
|
template<bool only_move>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user