Sublime Forum

Syntax Highlighting broken in Sublime Text 4

#1

Hey all,
I recently upgraded from Sublime Text 3 to Sublime Text 4. I’m not going to say I’m super familiar with the whole ecosystem; I just like to install packages via Package Control and use them where need be. I’ll try to explain the problem as best I can.

I do a good amount of development with a language called SPARQL. To highlight the syntax of this language correctly I had installed a custom package via Package Control called LinkedData, and I had been using it successfully for a while on Sublime Text 3. However it seems like when I updated to ST4, something broke. Here’s what my SPARQL files currently look like:

The weird thing is, when I try to change my Color Scheme, I get a brief moment of things going back to normal until I hit escape to go out of the prompt (I will put this image in a reply to this topic since new users can only have one image per post)

As soon as I hit escape from that prompt, the editor goes right back to the first image.

Please let me know if there is any other files, images, or troubleshooting I can provide to help out.
Thanks!

0 Likes

Having Issue with Syntax Highlighting in Sublime Text
#2

Here is the second image, referenced in the first post:

0 Likes

#3

Does it happen in safe mode? Does it happen with other syntaxes?

0 Likes

#4

Hi bschaaf, thanks for the comment! It actually does not happen in safe mode, and it looks like my syntax is being highlighted correctly. How can I troubleshoot further to see what the actual issue is?

0 Likes

#5

As a sanity check, if you follow the steps you outlined above, if you actually select a color scheme (instead of pressing escape, does the problem persist?

From the looks of things, the issue may be related to your color scheme having color rules that make text illegible, so trying a different color scheme would be a way to check that (in safe mode, the color scheme used is Mariana, for example).

If that’s the case, the first step would be to swap at least temporarily to a different color scheme, and if you can point us as what color scheme you’re using that’s making this happen that would allow us to look into what’s going on.

0 Likes

#6

Apologies for the delay between my responses, I got wrapped up in work a bit.

For clarity, I’ll give the rundown first:

  • I thought I started in safe mode, but I did not. I held CMD while double-clicking the Sublime Text icon, instead of Option.
  • When I start in Safe Mode, none of the syntax highlighters are available, since I’ve installed these from PackageControl.
  • Even though I was not in safe mode, the test file I was using was being highlighted correctly.
  • Ever since then I haven’t been able to reproduce the correct highlighting, whether I’m in safe mode or not.
  • I’m not sure what would cause the inconsistent behavior.

I’ve also linked a video of me selecting different Color Schemes while a test file is in the background. The syntax I’m using is available on Package Control via the LinkedData package. For clarity, in the video I hit Enter on the NaturalContrast color scheme, and I also hit enter on the Monokai color scheme after that.

https://drive.google.com/file/d/1uYI2MRHNWnKXl6mJ0qCaUOUAHEPg1Glc/view?usp=sharing

0 Likes

#7

The previews that you see as you select items look correct, but purely from the video it looks like you’re pressing esc to close the panel, since things don’t change. If you’re actually pressing enter something is hinky there. If you do Preferences > Settings, do you see the color_scheme setting changing when you select a different item from the panel and press enter?

If you see it changing (you may need to select all in the file to see it due to your issue) but files still don’t see any visible change, then the reason would be that a plugin is forcing the color scheme to something else, or a syntax-specific setting is doing the same (in which case you would see this problem happen in some times of files but not in other types of files).

If none of that is the case, then I would try a couple of things:

  1. Use Preferences > Browse Packages from the command palette or the menu
  2. Do you see a folder named Default? If yes, move it away to your desktop or similar and restart Sublime
  3. Go up one level and into Installed Packages; do you see a Default.sublime-package there? If yes, move it away to your desktop or similar and restart Sublime
0 Likes

#8

I would agree that the previews I’m seeing look correct, and I could see why you think I’m hitting escape here. Alas, that is not the case. Here’s another video of me changing the theme, and the theme in my preferences changing along with it:
https://drive.google.com/file/d/1HhCdAd3_Bwv2l2TSX_jiSnuRUfP59BIu/view?usp=sharing

I also have no Default folder in my Packages directory:

and there is no Default.sublime-package in my Installed Packages directory: (image coming in the next reply as new users can only post one image per post)

0 Likes

#9

Here is my Installed Packages directory:

0 Likes

#10

What do you see if you use Preferences > Settings - Syntax Specific while the SQL looking file has the input focus?

Something else to try would be while you have that particular file open opening the Sublime console and entering view.settings().erase("color_scheme") to see if that has any effect on things.

0 Likes

#11

For clarity, this is not an SQL file, it’s a query format called SPARQL and I have installed a custom package to have the syntax highlighted (the package worked on Sublime Text 3).

It doesn’t seem like I can post another link to a file on Google Drive for some reason? The Preferences > Settings - Syntax Specific file did not change when I changed color schemes with it open.

Entering view.settings().erase("color_scheme") into the console which the file was open did not have any effect.

0 Likes

#12

The idea is that if the syntax specific settings file contains a color_scheme key, it will override the global and always be used for that type of file, in which case I would expect that changing the setting would have no effect.

If that’s the case removing the value from that config file would allow the global to be set, which might solve the issue.

0 Likes

#13

Ah, ok. I think I’m following. I went ahead and unzipped the LinkedData.sublime-package file, and checked the sparql.sublime-settings. Here’s the full entry:

{
	"color_scheme": "Packages/LinkedData/macaron-dark.sublime-color-scheme"
}

Does this mean that it’s overriding the global color scheme and using macaron-dark? How can I change this if it’s not present when I go to Settings -> Syntax Specific?

0 Likes

#14

Ah yes, if I manually set the Color Scheme to Mariana.sublime-color-scheme in Settings -> Syntax Specific, it does update the colors I’m seeing in the SPARQL file. Is there a better way to do this other than updating the syntax preferences for all of the filetypes in the LinkedData package?

0 Likes

#15

The LinkedData package should ideally just not set any color schemes at all. Open a feature request on its repository.

1 Like

#16

Thank you for all of your help, it looks like an issue was opened on the GitHub repo. I’ve commented there and I believe it should be fixed by the LinkedData package not setting a color_scheme. The issue thread can be seen here:

1 Like