take into account tab characters when counting line row heights

This commit is contained in:
Josh Holtrop 2016-12-21 18:36:47 -05:00
parent f7d0c8189a
commit 9733d577a7

View File

@ -27,6 +27,18 @@ int BufferPane::rows_in_line(const Buffer::Iterator & start_of_line)
{ {
break; break;
} }
else if (code_point == '\t')
{
uint8_t tabstop = m_buffer->tabstop();
screen_column += tabstop - screen_column % tabstop;
if (screen_column > m_columns)
{
screen_column -= m_columns;
rows++;
}
}
else
{
int c_width = character_width(code_point); int c_width = character_width(code_point);
if (((screen_column + c_width) > m_columns) && if (((screen_column + c_width) > m_columns) &&
(c_width <= m_columns)) (c_width <= m_columns))
@ -39,6 +51,7 @@ int BufferPane::rows_in_line(const Buffer::Iterator & start_of_line)
screen_column += c_width; screen_column += c_width;
} }
} }
}
return rows; return rows;
} }
@ -62,6 +75,18 @@ int BufferPane::rows_in_line_with_iterator_offset(const Buffer::Iterator & start
} }
break; break;
} }
else if (code_point == '\t')
{
uint8_t tabstop = m_buffer->tabstop();
screen_column += tabstop - screen_column % tabstop;
if (screen_column > m_columns)
{
screen_column -= m_columns;
rows++;
}
}
else
{
int c_width = character_width(code_point); int c_width = character_width(code_point);
if (((screen_column + c_width) > m_columns) && if (((screen_column + c_width) > m_columns) &&
(c_width <= m_columns)) (c_width <= m_columns))
@ -74,6 +99,7 @@ int BufferPane::rows_in_line_with_iterator_offset(const Buffer::Iterator & start
screen_column += c_width; screen_column += c_width;
} }
} }
}
return rows; return rows;
} }