Do not use any display information to determine where the cursor moves
This commit is contained in:
parent
3a3144f3f5
commit
93408e4b76
|
@ -1242,8 +1242,7 @@ private:
|
||||||
auto& selections = context().selections();
|
auto& selections = context().selections();
|
||||||
for (auto& sel : selections)
|
for (auto& sel : selections)
|
||||||
{
|
{
|
||||||
auto cursor = context().has_window() ? context().window().offset_coord(sel.cursor(), offset)
|
auto cursor = context().buffer().offset_coord(sel.cursor(), offset);
|
||||||
: context().buffer().offset_coord(sel.cursor(), offset);
|
|
||||||
sel.anchor() = sel.cursor() = cursor;
|
sel.anchor() = sel.cursor() = cursor;
|
||||||
}
|
}
|
||||||
selections.sort_and_merge_overlapping();
|
selections.sort_and_merge_overlapping();
|
||||||
|
|
|
@ -1696,9 +1696,7 @@ void move(Context& context, NormalParams params)
|
||||||
auto& selections = context.selections();
|
auto& selections = context.selections();
|
||||||
for (auto& sel : selections)
|
for (auto& sel : selections)
|
||||||
{
|
{
|
||||||
auto cursor = context.has_window() ? context.window().offset_coord(sel.cursor(), offset)
|
auto cursor = context.buffer().offset_coord(sel.cursor(), offset);
|
||||||
: context.buffer().offset_coord(sel.cursor(), offset);
|
|
||||||
|
|
||||||
sel.anchor() = mode == SelectMode::Extend ? sel.anchor() : cursor;
|
sel.anchor() = mode == SelectMode::Extend ? sel.anchor() : cursor;
|
||||||
sel.cursor() = cursor;
|
sel.cursor() = cursor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,38 +322,13 @@ BufferCoord Window::buffer_coord(DisplayCoord coord) const
|
||||||
return {0,0};
|
return {0,0};
|
||||||
if (coord <= 0_line)
|
if (coord <= 0_line)
|
||||||
coord = {0,0};
|
coord = {0,0};
|
||||||
if ((int)coord.line >= m_display_buffer.lines().size())
|
if ((size_t)coord.line >= m_display_buffer.lines().size())
|
||||||
coord = DisplayCoord{(int)m_display_buffer.lines().size()-1, INT_MAX};
|
coord = DisplayCoord{(int)m_display_buffer.lines().size()-1, INT_MAX};
|
||||||
|
|
||||||
return find_buffer_coord(m_display_buffer.lines()[(int)coord.line],
|
return find_buffer_coord(m_display_buffer.lines()[(int)coord.line],
|
||||||
buffer(), coord.column);
|
buffer(), coord.column);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord Window::offset_coord(BufferCoord coord, CharCount offset)
|
|
||||||
{
|
|
||||||
return buffer().offset_coord(coord, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferCoordAndTarget Window::offset_coord(BufferCoordAndTarget coord, LineCount offset)
|
|
||||||
{
|
|
||||||
auto line = clamp(coord.line + offset, 0_line, buffer().line_count()-1);
|
|
||||||
DisplayBuffer display_buffer;
|
|
||||||
DisplayBuffer::LineList& lines = display_buffer.lines();
|
|
||||||
lines.emplace_back(AtomList{ {buffer(), coord.line, coord.line+1} });
|
|
||||||
lines.emplace_back(AtomList{ {buffer(), line, line+1} });
|
|
||||||
display_buffer.compute_range();
|
|
||||||
|
|
||||||
BufferRange range{ std::min(line, coord.line), std::max(line,coord.line)+1};
|
|
||||||
|
|
||||||
InputHandler input_handler{{ *m_buffer, Selection{} }, Context::Flags::Transient};
|
|
||||||
input_handler.context().set_window(*this);
|
|
||||||
m_highlighters.highlight(input_handler.context(), HighlightFlags::MoveOnly, display_buffer, range);
|
|
||||||
m_builtin_highlighters.highlight(input_handler.context(), HighlightFlags::MoveOnly, display_buffer, range);
|
|
||||||
|
|
||||||
ColumnCount column = coord.target == -1 ? find_display_column(lines[0], buffer(), coord) : coord.target;
|
|
||||||
return { find_buffer_coord(lines[1], buffer(), column), column };
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::clear_display_buffer()
|
void Window::clear_display_buffer()
|
||||||
{
|
{
|
||||||
m_display_buffer = DisplayBuffer{};
|
m_display_buffer = DisplayBuffer{};
|
||||||
|
|
|
@ -44,9 +44,6 @@ public:
|
||||||
bool needs_redraw(const Context& context) const;
|
bool needs_redraw(const Context& context) const;
|
||||||
void force_redraw() { m_last_setup = Setup{}; }
|
void force_redraw() { m_last_setup = Setup{}; }
|
||||||
|
|
||||||
BufferCoord offset_coord(BufferCoord coord, CharCount offset);
|
|
||||||
BufferCoordAndTarget offset_coord(BufferCoordAndTarget coord, LineCount offset);
|
|
||||||
|
|
||||||
void set_client(Client* client) { m_client = client; }
|
void set_client(Client* client) { m_client = client; }
|
||||||
|
|
||||||
void clear_display_buffer();
|
void clear_display_buffer();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user