dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
22.74k stars 380 forks source link

🐛 Syntax highlighting fails when the visible snippet includes a multiline comment #1606

Closed j1ah0ng closed 8 months ago

j1ah0ng commented 8 months ago

It seems that in the case where the diff window happens to include the start of a multiline string (e.g. in this Python example ""') the rest of the output is treated as a comment. See the second block in the image:

image

Raw output:

diff --git a/foo/make_docs.py b/foo/make_docs.py
index 9659c1f45a13..5e28ceca62c0 100644
--- a/foo/make_docs.py
+++ b/foo/make_docs.py
@@ -183,11 +183,7 @@ class LgtmSlicerDocumentationProvider(DocumentationProvider):
                 slicers.append(slicer_dict)

         slicers.sort(key=lambda x: x["name"])
-        environment = Environment(
-            loader=FileSystemLoader(
-                self.get_execroot() / "foo"
-            )
-        )
+        environment = Environment(loader=FileSystemLoader(Path(__file__)))
         template = environment.get_template(TEMPLATE_FILE)

         rendered_output = template.render(slicers=slicers)
diff --git a/bar/make_docs.py b/bar/make_docs.py
index c8cdf1d24c8d..8101faf58ba5 100644
--- a/bar/make_docs.py
+++ b/bar/make_docs.py
@@ -665,11 +665,7 @@ class AttributeGeneratorDocumentationProvider(DocumentationProvider):
         """
         attributes, messages, topics = self.process_all_topics()

-        environment = Environment(
-            loader=FileSystemLoader(
-                self.get_execroot() / "bar"
-            )
-        )
+        environment = Environment(loader=FileSystemLoader(Path(__file__)))
         msgs_template = environment.get_template(MSG_TEMPLATE_FILE)
         msgs_rendered_output = msgs_template.render(
             sections={

Thanks for filing a Delta bug report!

j1ah0ng commented 8 months ago

This may be fixed by #1091

dandavison commented 8 months ago

Hi @j1ah0ng, thanks for reminding me about #1091. I'm going to close this because it's a dup of #117, but I agree -- I have wanted this to be improved for a long time, and #1091 seems like a good suggestion.