diff --git a/src/gui/BufferPane.cc b/src/gui/BufferPane.cc index 3a2b581..2b851f1 100644 --- a/src/gui/BufferPane.cc +++ b/src/gui/BufferPane.cc @@ -27,16 +27,29 @@ int BufferPane::rows_in_line(const Buffer::Iterator & start_of_line) { break; } - int c_width = character_width(code_point); - if (((screen_column + c_width) > m_columns) && - (c_width <= m_columns)) + else if (code_point == '\t') { - rows++; - screen_column = c_width; + uint8_t tabstop = m_buffer->tabstop(); + screen_column += tabstop - screen_column % tabstop; + if (screen_column > m_columns) + { + screen_column -= m_columns; + rows++; + } } else { - screen_column += c_width; + int c_width = character_width(code_point); + if (((screen_column + c_width) > m_columns) && + (c_width <= m_columns)) + { + rows++; + screen_column = c_width; + } + else + { + screen_column += c_width; + } } } return rows; @@ -62,16 +75,29 @@ int BufferPane::rows_in_line_with_iterator_offset(const Buffer::Iterator & start } break; } - int c_width = character_width(code_point); - if (((screen_column + c_width) > m_columns) && - (c_width <= m_columns)) + else if (code_point == '\t') { - rows++; - screen_column = c_width; + uint8_t tabstop = m_buffer->tabstop(); + screen_column += tabstop - screen_column % tabstop; + if (screen_column > m_columns) + { + screen_column -= m_columns; + rows++; + } } else { - screen_column += c_width; + int c_width = character_width(code_point); + if (((screen_column + c_width) > m_columns) && + (c_width <= m_columns)) + { + rows++; + screen_column = c_width; + } + else + { + screen_column += c_width; + } } } return rows;