From ea5fb2c8fa3142673c01f9505480ba971e498754 Mon Sep 17 00:00:00 2001 From: TomJGooding <101601846+TomJGooding@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:08:42 +0000 Subject: [PATCH 1/3] fix(tree-sitter): remove slow html highlight patterns Fixes #4152 by removing all `((element (start_tag (tag_name) @_tag)` patterns from the `html.scm` highlights query file. These patterns will cause a segfault on relatively large documents and even just one seems a massively expensive operation from some quick testing. All tests pass after removing these and I couldn't see they were actually used anywhere in syntax highlighting, but please correct me if I'm wrong! --- src/textual/tree-sitter/highlights/html.scm | 39 --------------------- 1 file changed, 39 deletions(-) diff --git a/src/textual/tree-sitter/highlights/html.scm b/src/textual/tree-sitter/highlights/html.scm index 15f2adb436..41c83ce0d8 100644 --- a/src/textual/tree-sitter/highlights/html.scm +++ b/src/textual/tree-sitter/highlights/html.scm @@ -6,45 +6,6 @@ (quoted_attribute_value) @string) (text) @text @spell -((element (start_tag (tag_name) @_tag) (text) @text.title) - (#eq? @_tag "title")) - -((element (start_tag (tag_name) @_tag) (text) @text.title.1) - (#eq? @_tag "h1")) - -((element (start_tag (tag_name) @_tag) (text) @text.title.2) - (#eq? @_tag "h2")) - -((element (start_tag (tag_name) @_tag) (text) @text.title.3) - (#eq? @_tag "h3")) - -((element (start_tag (tag_name) @_tag) (text) @text.title.4) - (#eq? @_tag "h4")) - -((element (start_tag (tag_name) @_tag) (text) @text.title.5) - (#eq? @_tag "h5")) - -((element (start_tag (tag_name) @_tag) (text) @text.title.6) - (#eq? @_tag "h6")) - -((element (start_tag (tag_name) @_tag) (text) @text.strong) - (#any-of? @_tag "strong" "b")) - -((element (start_tag (tag_name) @_tag) (text) @text.emphasis) - (#any-of? @_tag "em" "i")) - -((element (start_tag (tag_name) @_tag) (text) @text.strike) - (#any-of? @_tag "s" "del")) - -((element (start_tag (tag_name) @_tag) (text) @text.underline) - (#eq? @_tag "u")) - -((element (start_tag (tag_name) @_tag) (text) @text.literal) - (#any-of? @_tag "code" "kbd")) - -((element (start_tag (tag_name) @_tag) (text) @text.uri) - (#eq? @_tag "a")) - ((attribute (attribute_name) @_attr (quoted_attribute_value (attribute_value) @text.uri)) From eed79bff574ee6299d21ea1cdee7a967c18216aa Mon Sep 17 00:00:00 2001 From: TomJGooding <101601846+TomJGooding@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:01:11 +0000 Subject: [PATCH 2/3] run tests in ci --- src/textual/widgets/_text_area.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textual/widgets/_text_area.py b/src/textual/widgets/_text_area.py index f700a742f3..327caa82dd 100644 --- a/src/textual/widgets/_text_area.py +++ b/src/textual/widgets/_text_area.py @@ -674,7 +674,7 @@ def _watch_show_line_numbers(self) -> None: self.scroll_cursor_visible() def _watch_indent_width(self) -> None: - """Changing width of tabs will change document display width.""" + """Changing width of tabs will change the document display width.""" self._rewrap_and_refresh_virtual_size() self.scroll_cursor_visible() From 251aa9c84b2ee5f1a0d4c85b57eeb10efec7a40e Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 22 Feb 2024 12:57:43 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e8de9633..a3534132aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed `TextArea.code_editor` missing recently added attributes https://github.com/Textualize/textual/pull/4172 - Fixed `Sparkline` not working with data in a `deque` https://github.com/Textualize/textual/issues/3899 - Tooltips are now cleared when the related widget is no longer under them https://github.com/Textualize/textual/issues/3045 +- Simplified tree-sitter highlight queries for HTML, which also seems to fix segfault issue https://github.com/Textualize/textual/pull/4195 ## [0.52.1] - 2024-02-20