-
Notifications
You must be signed in to change notification settings - Fork 48
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
Emacs 27.1 string highlighting and indentation issues #175
Comments
Hi there! I am aware of this issue, and it is an emacs 27.1 specific issue. I cannot reproduce it in 26.3 or master branch. The simplest way to fix this is by compiling emacs from master, downloading 28.50 snapshot or using 26.3. However, I will take some time this evening and locate the offending code. I hope disabling this for 27.1 only will mitigate this, but I think the error lies with emacs itself. I will keep this issue open rather than reopening the other, since what was a solution there doesn't apply any more after the rework. I'll ping you when I have something 😄 |
@theothornhill it appears it has to do with the change in 27.1 to more efficiently fontify strings? I thought there was a way to turn it off, but I can't find anything that corroborates it 😄 |
Actually, it is the multiline strings variables fault. (c-lang-defconst c-multiline-string-start-char
csharp ?@) This code is the culprit, and as such the problem is in emacs. I'm bisecting as we speak to see where exactly it was fixed after the release of 27.1. You can try yourself by commenting out that code and re-evaling |
Ok! emacs-mirror/emacs@dddc971 on emacs is the commit that fixed this. |
@grendello is this fixed after c7bdaeb? @tplinux This should be the same as in #151 - is it fixed for you too? |
@theothornhill yep, it seems to have done it! :) Great, thanks! |
Amazing! Closing this one, then 🥳 |
Thanks for fixing this :) |
Hi,
First of all, thank you for this mode, it's been making C# editing on Emacs a pleasure over quite a few years and hopefully for many years to come :)
After switching to Emacs 27.1 I started to notice the string fontification problem that was fixed and seemed to disappear a few days ago (last week?) but now it seems to be back :(
When editing string-heavy code csharp-mode still sometimes gets lost and causes cc-mode to detect incorrect context, apply incorrect indentation as well as highlighting code following a certain point as strings.
Sometimes when the code is highlighted as string manual indentation (using tab) works, but electric indentation does not. Sometimes the code is treated fully as a string, in which case neither indentation works
correctly. Sometimes letting Emacs go idle for a few moments "fixes" cc-mode's understanding of the context and indentation starts to work again. When that happens calling
font-lock-fontify-buffer
fixes thehighlighting as well.
I can't put the finger on what precisely triggers the issue, but in most cases it can be "fixed" by finding the end of some string above your current position, add a space after it and save the buffer.
The attached screenshot is a work-in-progress of a file I'm currently refactoring, you can see the syntax context shown in the echo area is incorrect. In this particular file, I need to go up around 80 lines to find the
"offending" string which triggers the misbehavior. You can find the WIP file here (you will need
to create
.projectile
in the same directory before opening it in Emacs since OmniSharp Roslyn gets lost in the Xamarin.Android solution currently and you'd get plenty of errors without.projectile
)I'm using the latest version of
csharp-mode
available from MELPA (20201007.1738
) and the latest release of OmniSharp Roslyn (1.37.1) running under Mono/master (commite0437b3ec11
)The text was updated successfully, but these errors were encountered: