mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-21 23:54:57 +00:00
Allow trailing comments in shader pipeline files\n\nFixes #10718
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
This commit is contained in:
parent
3625d3494d
commit
f9b57ba283
3 changed files with 14 additions and 2 deletions
|
|
@ -260,7 +260,8 @@ The pipeline part
|
|||
|
||||
A pipeline file (:file:`.pipeline`) is a plain text file that controls how
|
||||
one or more shaders are assembled into a rendering pipeline. Lines starting
|
||||
with ``#`` are comments; blank lines are ignored.
|
||||
with ``#`` are comments, as is everything after a ``#`` that is preceded by
|
||||
whitespace; blank lines are ignored.
|
||||
|
||||
**Top-level directives** (outside any group):
|
||||
|
||||
|
|
|
|||
|
|
@ -1658,6 +1658,11 @@ class Pipeline(TypedDict):
|
|||
pipeline_dir: str
|
||||
|
||||
|
||||
@run_once
|
||||
def trailing_comment_pat() -> re.Pattern[str]:
|
||||
return re.compile(r'\s#.*')
|
||||
|
||||
|
||||
def parse_pipeline_definition(lines: Iterable[str], pipeline_name: str, pipeline_dir: str = '') -> Pipeline:
|
||||
slot = Slot.end
|
||||
textures: tuple[NamedTexture, ...] = ()
|
||||
|
|
@ -1701,7 +1706,8 @@ def parse_pipeline_definition(lines: Iterable[str], pipeline_name: str, pipeline
|
|||
}
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
# A # at the start of the line or preceded by whitespace starts a comment
|
||||
line = trailing_comment_pat().sub('', line).strip()
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
parts = line.split()
|
||||
|
|
|
|||
|
|
@ -118,6 +118,11 @@ class TestSlang(BaseTest):
|
|||
g = pipeline('animation_start user:find-cursor|tab-change\nanimation_stop user:x.y_z')['groups'][0]
|
||||
self.ae(g['animation_start'], ('user:find-cursor', 'tab-change'))
|
||||
self.ae(g['animation_end_events'], ('user:x.y_z',))
|
||||
# Trailing comments, including empty ones
|
||||
for comment in ('# ', '#', '# some comment', '\t#x'):
|
||||
g = pipeline(f'animation_toggle user:toggle-notch {comment}\nanimation_duration 600 {comment}')['groups'][0]
|
||||
self.ae(g['animation_toggle'], ('user:toggle-notch',))
|
||||
self.ae(g['animation_duration'], 600_000_000)
|
||||
for bad in ('user:', 'user:a/b', 'user:' + 'x' * 100, 'usr:a'):
|
||||
self.assertRaises(ValueError, pipeline, f'animation_start {bad}')
|
||||
# A toggled group stays on until toggled off unless told otherwise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue