Sublime Forum

Incorrect diff highlighting

#1

I’m using the latest version of sublime merge and when I’m viewing diffs I get a lot of extra highlighting that shouldn’t be highlighted.

As you can see from another git client the only change is NSView to DirectoryView, but Merge seems to include additional highlighting for no reason. I really like merge, but this is making it unusable for me.

1 Like

#2

The red background looks like invalid highlighting caused by the syntax definition. Which language is it?

2 Likes

#3

The language is Swift

0 Likes

#4

Do you see the same errors in Sublime Text for that file?

0 Likes

#5

No, I don’t see any issues in Sublime Text, but I think @deathaxe is correct because I don’t see this issue for other file types. Is it possible to turn off syntax highlighting?

0 Likes

#6

You can Menu > Edit Settings… to open the Preferences.sublime-settings and add

	"ignored_packages":
	[
		"Swift"
	],

SM and ST share many settings.

Nevertheless it’s a bit curious for SM to fail with a file which works in ST as both use the same engine.

2 Likes

#8

@corysullivan, few questions:

  1. Is this Swift package the one you had installed in Sublime Text for Swift support?
  2. Is whitespace ignored? Does the error go away if you toggle ignore whitespace?
  3. Was there a diff block above the one in the image that included changes in or around a string?

@deathaxe, the Swift package is 3 years old & still uses .tmLanguage files. The only invalid scope in the syntax is for illegal characters within a string. Since every built-in language uses .sublime-syntax, I wonder if SM doesn’t handle syntax highlighting with added/removed lines with the old-school structures. (at the moment, I’m guessing SM is not running the syntax highlighter for each version of the file)

0 Likes

#9
  1. Is this Swift package the one you had installed in Sublime Text for Swift support?

yes, that is the package I was using, however, I have since uninstalled it and I still see the problem.

  1. Is whitespace ignored? Does the error go away if you toggle ignore whitespace?

Do you mean whitespace visibility? Because I tried changing that and it has no effect.

In that case, no there was not. But I see this red highlighting everywhere, it’s not just related to the diff view. If a select a file from the view tree, it still shows red.

0 Likes

#10

This red highlighting started happening to me recently also. Not sure what if anything I changed. I do not have any packages installed. It seems to be happening for me in .tfvars files. But I have been editing these kinds of files for years, with no highlighting. Why would this highlighting just have been turned on now, somehow? When I open the same files in Sublime Text, there is no highlighting. Only in Sublime Merge.

1 Like

#11

Indeed…this has been my experience too.

Anyone from Sublime care to comment?

Thank you.

Sublime Merge: Stable Channel, Build 2112

0 Likes

#12

Neither Sublime Text nor Sublime Merge ship with syntax definitions for Terraform, nor do they assign related extensions.

Sublime Merge re-uses Sublime Text packages from ~/.config/sublime-text/Installed Packages or ~/.config/sublime-text/Packages to “ensure” both applications support same set of syntax definitions.

If Terraform files are syntax highlighted, it means

  1. there’s either a package claiming support for .tfvars files
  2. any syntax-specific settings file assigns this extension to a (wrong?) syntax definition.

I haven’t seen SM highlighting diffs wrong, related files of which wouldn’t also be highlighted badly in ST - which is then caused by a bug of a syntax definiiton.

An up-to-date syntax definition for Terraform can be found at https://packagecontrol.io/packages/Terraform.

Same applies to basically any language, as discussed for Swift before.

1 Like

#13

Thank you for your response.

My question/comment wasn’t related to Terraform; in my case it is Python. I was merely echoing the observation that certain syntax in Python was incorrectly highlighted in a diff in SM.

I “fixed” it using your suggestion:

"ignored_packages":
[
	"Python"
],

but I must admit that this feels wrong (i.e., I shouldn’t have to do this).

What is surprising is that SM was working fine until just a few weeks ago when this “red highlight” started appearing in the diffs. I do not know if this is a result of a Python-related package upgrade, or an SM upgrade.

Thank you.

0 Likes

#14

I haven’t come accross such illegal highlighting when working on python code, using bleeding edge ST & SM dev builds, so far. Not even in diffs related to from ... import statements.

I also don’t see any such issues with freshly installed portable SM 2112 on Windows.

I am not aware of ST/SM’s python syntax to scope those imports illegal, but the way it is highlighted indicates it being caused by syntax definition. What’s interesting is, all but the line 4th line containing a diff, being highlighted illegal.

If there’s no out-dated Python package overriding the default one, I wouldn’t have an explenation at hand for what could be causing this odd illegal highlighting.

0 Likes