in all in one view mode show file status (modified/staged/added/deleted/undecided/?)

This commit is contained in:
Vaclav Tvrdik
2026-10-10 15:02:39 +02:00
parent f18bad79cd
commit cf120991bc
6 changed files with 48 additions and 9 deletions

View File

@@ -722,6 +722,24 @@ def all_files_view():
return view, st
def test_all_files_headings_show_the_status_letter_before_the_counts():
from vdiff import parse
view = sublime.View()
st = state.ViewState("/repo")
st.all_mode = True
st.files = [git.FileChange("a - b.py", "M", True, 1, 0, None), change("m.py"), change("gone.py", "D")]
lines = [parse.Line("+", None, 1, "x")]
st.all_diffs = {c.path: (lines, parse.change_blocks(lines), False) for c in st.files}
commands.render.render_all(view, st)
headings = [row for row in view.text.split("\n") if row.startswith("▼")]
# staged wins over the git letter; a path containing " -" must not confuse the letter's position
assert headings == ["▼ a - b.py s -0 +1", "▼ m.py m -0 +1", "▼ gone.py d -0 +1"]
regions, scope, _, _ = view.regions[commands.render.KEY_FILE_STATUS]
assert scope == commands.render.palette.SCOPE_FILE_STATUS
assert [view.text[r.a:r.b] for r in regions] == ["s", "m", "d"]
def heading_row(st, path):
return next(i for i, (c, _, section) in enumerate(st.all_rows) if section and c.path == path)

View File

@@ -147,3 +147,13 @@ def test_file_header_colours_come_from_settings(tmp_path, monkeypatch):
assert rules[palette.SCOPE_FILE_INS_COUNT]["background"] == "#202040"
assert rules[palette.SCOPE_FILE_INS_COUNT]["foreground"] == "#00ff00"
assert rules[palette.SCOPE_FILE_DEL_COUNT]["foreground"] == palette.FILE_DEL_FOREGROUND
def test_the_status_letter_is_white_on_the_heading_unless_set(tmp_path, monkeypatch):
palette.ensure(sublime.View())
rule = by_scope(tmp_path)[palette.SCOPE_FILE_STATUS]
assert rule["foreground"] == palette.FILE_STATUS_FOREGROUND == "#ffffff"
assert rule["background"] == by_scope(tmp_path)[palette.SCOPE_FILE_HEADER]["background"]
colour_option(monkeypatch, "file_header_status_foreground", "#ffff00")
palette.ensure(sublime.View())
assert by_scope(tmp_path)[palette.SCOPE_FILE_STATUS]["foreground"] == "#ffff00"