-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong font lock used when highlighting an element containing a string with punctuation inside #82
Comments
Glad it's not just me, I run into this a lot. I don't think line 46 is special in general, just in your example. Here's the simplest case I've managed to find: a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
a: 'a.a'
a: 'a'
(issue is present on the last line) EDIT: just realized there needn't be quotes on the last line to observe the issue |
Thanks for providing another test case @eeshugerman, I've updated the title and description to better fit both scenarios. |
It seems this bit is to blame -- if I remove it, this issue is resolved. Of course, removing it re-introduces the issue that it's there to solve (see the comment). Unless someone can get to the bottom of this one, I'd argue it makes sense to remove it. IMO the case that it improves (quotes in unquoted strings) is more of an edge-case than the case that it breaks (punctuation in quoted strings), and (all else equal) less code is better than more code. @wasamasa, thoughts? |
My thought on this is that I'm not going to remove code introduced by @dgutov (it's easily the most sophisticated contribution so far and he's a core Emacs developer), so battle it out with him. |
Two things:
So... I would suggest two avenues for research: a) try checking out that older version and see whether the problems is still there, b) some print-debugging, I guess? Also try some new version of Emacs (which ones are you seeing the problem with?) and running it with |
Thanks you two for chiming in! Sure enough, I do not observe the issue with I'm using Spacemacs, so I suppose there are a lot of places this could be going awry 😕. @codrut-fc are you using Spacemacs perchance? And/or Evil? I'm using v27.1. IIRC I saw the issue on v26.3 as well. I'll look into installing v28/master.
|
@eeshugerman yes, using Spacemacs:
Config file available here: https://gitlab.com/sdwolfz/dotfiles/-/blob/master/.spacemacs |
That was one of the first things I tried. ;-( If Spacemacs is what triggers it, someone should bisect its configuration. Either of you can do it, or you can file an issue at the Spacemacs issue tracker, I guess... |
I've actually looked through the Spacemacs source and I could not find anything that touches yaml-mode internals. Will try again, maybe it's not Spacemacs itself but another package installed somewhere (ansible comes to mind as it relies on yaml-mode) |
Could be something else that's generally font-lock related, for example. If you can comment out whole parts of the Spacemacs configuration at a time, that should make for a faster search. |
@dgutov do you have any tips on "live debugging" this as the file loads? I can't seem to figure out a way to visualise and understand what's happening. |
You could try https://github.com/Lindydancer/font-lock-studio, I suppose. Or print-debugging (meaning adding some I do believe you would be better served by bisecting the config, to find the smallest possible configuration where the bug can be reproduced first, either way. |
I'll close this issue for now, hopefully I'll have time to investigate more into this soon... |
Picking this up because it has been annoying me for a while. When using the example from above, I find it interesting that any editing of the buffer fixes the fontification, as does I haven't looked very deep into this just now, but I'm wondering if this could be a situation where several properties can match and the order they're applied in matters. This would mean that any incremental edit would trigger a different order of application than a loading from scratch, or something along those lines. |
Properties? Syntax-propertize rules? I can understand that it's annoying, but we're unlikely to make much progress without having a simple repro scenario starting with a base Emacs session. |
@sulami, what's your config like? are you using spacemacs? |
Elliott Shugerman <notifications@github.com> writes:
@sulami, what's your config like? are you using spacemacs?
Not using Spacemacs. I've got my entire config over at
https://github.com/sulami/dotfiles, including a frozen set of
dependencies, if people want to take a stab at it before I have a
chance.
|
OK, I was under the impression that this was a Spacemacs specific bug, but since @sulami confimed it happens outside of it then do you want me to repoen the issue? |
I think I found the culprit, my test case does not reproduce if I
disable hl-todo. Conversely, I managed to reproduce like so:
```
em -Q -l yaml-mode/yaml-mode.el -l hl-todo/hl-todo.el --eval "(global-hl-todo-mode)" /tmp/y.yml
```
This being the latest yaml-mode and the hl-todo version pinned in my
dotfiles at this point in time (https://github.com/tarsius/hl-todo/tree/0598b98f63b623c1778cbd2e2f60b774b7a311b9).
The file opened contains the snippet discussed earlier.
|
Pinging @tarsius, maybe he has some quick insight to share (I personally can't figure it out). |
I don't immediately see what might be causing this. |
Note: I can also confirm that excluding the |
I'm not using Spacemacs, but have been bugged by this same issue. Disabling |
Thanks for finding the conflict, I'll try to look into it this weekend. |
If I remove Alternatively, adding this extra item to the (let ((case-fold-search nil)
(syntax-ppss-table (syntax-table)))
(with-syntax-table hl-todo--syntax-table
(funcall (if backward #'re-search-backward #'re-search-forward)
regexp bound t)))
|
It seems regexp search (or most movements of point, really) can trigger syntax-propertize-function invocation, and when that happens while an unexpected syntax table is in effect, weird things happen. Fixes yoshiki/yaml-mode#82. Suggested-by: Dmitry Gutov <dgutov@yandex.ru>
I have applied that work around. Thanks @dgutov! |
I can confirm this is fixed now, Thank you very much for looking into this! |
This bug:
happens after line 46 (for some reason).This is especially troublesome with
docker-compose.yml
file where you define port mappings like:I have no idea how to investigate/fix this myself, so I'm asking for help (please) 🙏 !
EDIT: see #82 (comment) below for an investigation done by @sulami.
The text was updated successfully, but these errors were encountered: