more horizontal scrolling fixes
This commit is contained in:
parent
e510bf8b96
commit
2dcdc0cf4b
|
@ -112,7 +112,6 @@ void Window::scroll_to_keep_cursor_visible_ifn()
|
||||||
{
|
{
|
||||||
const auto& first = main_selection().first();
|
const auto& first = main_selection().first();
|
||||||
const auto& last = main_selection().last();
|
const auto& last = main_selection().last();
|
||||||
const String& content = buffer()[last.line];
|
|
||||||
|
|
||||||
const LineCount offset = std::min<LineCount>(options()["scrolloff"].get<int>(),
|
const LineCount offset = std::min<LineCount>(options()["scrolloff"].get<int>(),
|
||||||
(m_dimensions.line - 1) / 2);
|
(m_dimensions.line - 1) / 2);
|
||||||
|
@ -138,30 +137,28 @@ void Window::scroll_to_keep_cursor_visible_ifn()
|
||||||
// (this is only valid if highlighting one line and multiple lines put
|
// (this is only valid if highlighting one line and multiple lines put
|
||||||
// the cursor in the same position, however I do not find any sane example
|
// the cursor in the same position, however I do not find any sane example
|
||||||
// of highlighters not doing that)
|
// of highlighters not doing that)
|
||||||
CharCount column = 0;
|
auto cursor = buffer().iterator_at(last);
|
||||||
|
CharCount buffer_column = 0;
|
||||||
|
CharCount non_buffer_column = 0;
|
||||||
for (auto& atom : lines.back())
|
for (auto& atom : lines.back())
|
||||||
{
|
{
|
||||||
if (atom.content.has_buffer_range() and
|
if (atom.content.has_buffer_range())
|
||||||
atom.content.begin() <= last and atom.content.end() > last)
|
|
||||||
{
|
{
|
||||||
column += atom.content.length();
|
if (atom.content.begin() <= last and atom.content.end() > last)
|
||||||
|
{
|
||||||
|
if (buffer_column < m_position.column)
|
||||||
|
m_position.column = buffer_column;
|
||||||
|
|
||||||
auto first_col = (first.line == last.line) ? content.char_count_to(first.column) : 0_char;
|
auto last_column = buffer_column + atom.content.length();
|
||||||
auto last_col = content.char_count_to(last.column);
|
if (last_column >= m_position.column + m_dimensions.column - non_buffer_column)
|
||||||
|
m_position.column = last_column - m_dimensions.column + non_buffer_column;
|
||||||
if (first_col < m_position.column)
|
|
||||||
m_position.column = first_col;
|
|
||||||
else if (column >= m_position.column + m_dimensions.column)
|
|
||||||
m_position.column = column - m_dimensions.column;
|
|
||||||
|
|
||||||
if (last_col < m_position.column)
|
|
||||||
m_position.column = last_col;
|
|
||||||
else if (column >= m_position.column + m_dimensions.column)
|
|
||||||
m_position.column = column - m_dimensions.column;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
column += atom.content.content().char_length();
|
buffer_column += atom.content.length();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
non_buffer_column += atom.content.length();
|
||||||
}
|
}
|
||||||
if (not buffer().is_end(last))
|
if (not buffer().is_end(last))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user