tighten the multi-line comments

This commit is contained in:
Vaclav Tvrdik
2026-09-29 15:10:26 +02:00
parent d6f0ed3009
commit 413731df47
10 changed files with 63 additions and 90 deletions

View File

@@ -13,8 +13,8 @@ sys.path.insert(0, os.path.join(HERE, "stubs"))
def scheme_override_sandbox(tmp_path, monkeypatch):
"""Keep the colour-scheme override palette.py writes inside the test's own tmp_path
Both caches are per session and the stub hands every view the same id, so they would otherwise
leak between tests and make every assertion about the override depend on test order.
Both caches are per session and every stub view shares one id, so they would otherwise leak and
make override assertions depend on test order.
"""
import sublime

View File

@@ -114,9 +114,8 @@ class Window:
return self.input_view
# a bundled scheme's styles: the diff.* and region.* scopes defined, the plugin's vdiff.* ones not.
# Nothing here simulates sublime merging in a written override, so a test that wants the plugin's
# scopes to resolve has to say so by adding them.
# a bundled scheme's styles: diff.* and region.* defined, the plugin's vdiff.* ones not. Nothing
# simulates sublime merging an override, so a test wanting those to resolve adds them itself.
DEFAULT_FG = "#ffffff"
DEFAULT_STYLES = {
"diff.deleted": {"foreground": DEFAULT_FG, "background": "#4a2b2b"},
@@ -246,8 +245,8 @@ class View:
def extract_tokens_with_scopes(self, region):
"""One token per run of word characters and one per run of anything else, scoped by its shape
Enough shape for the colouring tests: real sublime returns the syntax's tokens, and all the
painter needs is that adjacent tokens differ and each maps to a scope with a colour.
Enough for the colouring tests: real sublime returns the syntax's tokens, but the painter only
needs adjacent tokens to differ and each to map to a coloured scope.
"""
tokens = []
text = self.text[region.a:region.b]

View File

@@ -329,8 +329,8 @@ def test_commit_items_fall_back_for_an_empty_subject():
def loading(monkeypatch):
"""Queue run_async instead of running it inline, so a test can act mid-load like a user can
The stub runs set_timeout synchronously, which is why the real plugin's async window - the one
n / p used to read stale state through - is invisible to every other test in the suite.
The stub runs set_timeout synchronously, so the real async window — the one n / p read stale
state through — is invisible to every other test.
"""
queue = []
monkeypatch.setattr(commands, "run_async", lambda work, done: queue.append((work, done)))
@@ -522,8 +522,8 @@ def test_a_file_without_changes_neither_moves_nor_rings(rings):
def press(monkeypatch, action, before, path, after):
"""Run `action` on `path` of `before`; git then reports `after`. Returns the paths shown
ACTIONS captured git.stage and friends when the table was built, so the subprocess is stubbed
one level down, at git.run; that keeps the real wiring of the action under test.
ACTIONS captured git.stage and friends at build time, so the stub goes one level down at git.run,
keeping the action's real wiring under test.
"""
shown = []
monkeypatch.setattr(commands.git, "run", lambda repo, args, ok_codes=(0,): "")

View File

@@ -37,8 +37,7 @@ def header(view):
def with_loaded_override(view):
"""Model a view whose scheme has picked up the override palette.py writes
The stub deliberately does not simulate that merge, just as sublime does not until it restarts,
so a test wanting the generated colour scopes to resolve has to say so.
The stub no more simulates that merge than sublime does before a restart, so a test says so itself.
"""
view.override_loaded = True
return view
@@ -210,8 +209,8 @@ def test_keymap_matches_help_table():
def test_no_binding_yields_to_vintage_command_mode():
"""The review view is read-only, so its letters are vdiff commands in either vim mode
init_view opens the view in command mode; a binding that still carried the old
`command_mode: false` context would go dead there, which is what broke n / p.
init_view opens in command mode; a binding still carrying the old `command_mode: false` context
would go dead there, which is what broke n / p.
"""
guard = {"key": "setting.command_mode", "operand": False}
for binding in keymap_bindings():
@@ -222,8 +221,7 @@ def test_no_binding_yields_to_vintage_command_mode():
def test_minihtml_stylesheets_reject_unsupported_selectors():
"""minihtml drops the rest of a stylesheet at a selector it cannot parse; these are the forms
that silently broke HELP_CSS, so no stylesheet constant may use them"""
"""minihtml drops the rest of a stylesheet at an unparsable selector; these forms broke HELP_CSS"""
# descendant/child/sibling combinators, pseudo-classes, attribute selectors, compound classes
unsupported = re.compile(r"[\s:>~+\[]|[.#][^.#]*[.#]")
sheets = [(name, css) for name, css in vars(render).items() if name.endswith("_CSS") and isinstance(css, str)]
@@ -351,8 +349,8 @@ def test_changed_lines_are_repainted_in_the_files_own_colours():
keyword = view.styles["keyword"]["foreground"]
punctuation = view.styles["punctuation.definition"]["foreground"]
# " return 10" is an inserted line: its words carry the keyword colour, its spaces and digits
# are their own runs. Without this layer every one of them would be the tint's flat foreground.
# " return 10" is inserted: its words carry the keyword colour, its spaces and digits their
# own runs. Without this layer all of them would be the tint's flat foreground.
inserted = token_regions(view, "ins", keyword)
assert sublime.Region(view.text_point(4, 4), view.text_point(4, 10)) in inserted
# and a deleted line is painted from the deleted palette, not the inserted one
@@ -381,8 +379,8 @@ def test_token_layer_waits_for_the_scopes_to_resolve():
render.init_view(view)
render.render(view, make_state())
# sublime has not loaded the override yet, so the changed lines keep the scheme's flat tint and
# not one token key is painted: an unknown scope would draw its text in sublime's marker green
# the override is not loaded yet, so the lines keep the flat tint and no token key is painted:
# an unknown scope would draw its text in sublime's marker green
assert view.regions[render.KEY_DEL][1] == "diff.deleted"
assert view.regions[render.KEY_INS][1] == "diff.inserted"
assert not [key for key in view.regions if key.startswith("vdiff.tok.")]