Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,13 @@ void Controller::add_model(const std::string& filename) {
return lhs.filename.size() < rhs.filename.size();
})->filename.size();

std::string title = "\u2551 id \u2502 filename " + std::string(max_name_len - 8, ' ');
// "filename"
if (max_name_len < 8) {
max_name_len = 8;
}
max_name_len += 2;

std::string title = "\u2551 id \u2502 filename" + std::string(uint_t(max_name_len - 8), ' ');
title += " \u2502 pos \u2551";
std::size_t title_len = title.size() - 9;

Expand All @@ -759,21 +765,28 @@ void Controller::add_model(const std::string& filename) {
std::string line = "\u2551 " + std::to_string(idx);
line += " \u2502 ";
line += rawterm::bold(m.filename);

int spacing = 0;
if (max_name_len > m.filename.size()) {
spacing = max_name_len - m.filename.size();
}

if (m.unsaved) {
line += rawterm::bold("*");
if (m.filename.size() < max_name_len) {
line += std::string(max_name_len - m.filename.size() - 1, ' ');
}
} else {
line += std::string(max_name_len - m.filename.size() + 1, ' ');
spacing--;
}

if (spacing > 0) {
line += std::string(spacing, ' ');
}

line += " \u2502 ";
line += std::to_string(m.current_line + 1);
line.push_back(':');
line += std::to_string(m.current_char + 1);

std::size_t diff = title.size() - rawterm::raw_size(line) - std::string("\u2551").size();
const std::size_t diff =
title.size() - rawterm::raw_size(line) - std::string("\u2551").size();
line += std::string(diff, ' ');
line += "\u2551";

Expand Down
20 changes: 9 additions & 11 deletions tests/integration/command_mode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,16 @@ def test_list_open_buffers(r: TmuxRunner):
inverted_buf_name = "\x1B[7m[BUFFERS]\x1B[0m"
assert inverted_buf_name in r.await_tab_bar_parts()

lines: list[str] = r.lines()
assert "0" in lines[4]
assert "tests/fixture/temp_file.txt" in lines[4]
assert "1:1" in lines[4]

assert "1" in lines[5]
assert "NO NAME" in lines[5]
assert "1:1" in lines[5]
expected_lines: list[str] = [
"║ 0 │ tests/fixture/temp_file.txt │ 1:1 ║",
"║ 1 │ NO NAME │ 1:1 ║",
"║ 2 │ tests/fixture/test_file_1.txt │ 1:1 ║",
]

assert "2" in lines[6]
assert r.filename in lines[6]
assert "1:1" in lines[6]
lines: list[str] = r.lines()
assert expected_lines[0] in lines[4]
assert expected_lines[1] in lines[5]
assert expected_lines[2] in lines[6]

assert r.await_statusbar_parts()[1] == "[RO]"

Expand Down
Loading