Sublime Forum

Not rendered gutter icons in some cases

#1

I’m using add_regions(…) to add three differently named regions, different for three different lines. Problems is that only one of those icons is actually rendered. Or that’s what I see most of the time, it’s a bit random.

I’ve made some minimal test for this. Add this plugin:

[code]import sublime
import sublime_plugin

class OpenNewViewBugTestCommand(sublime_plugin.TextCommand):
def run(self, edit):
new_view = self.view.window().new_file()
new_view.insert(
edit,
0,
‘There should be three different coloured dots in the gutter.\n’
‘\na\nb\nc\n’)
lines_regions = new_view.lines(sublime.Region(0, new_view.size()))
new_view.add_regions(‘region1’,
[lines_regions[2]],
scope=‘comment’,
icon=‘circle’,
flags=sublime.HIDDEN)
new_view.add_regions(‘region2’,
[lines_regions[3]],
scope=‘markup.inserted’,
icon=‘circle’,
flags=sublime.HIDDEN)
new_view.add_regions(‘region3’,
[lines_regions[4]],
scope=‘markup.deleted’,
icon=‘circle’,
flags=sublime.HIDDEN)
[/code]

and run this code from the ST console to trigger it:

sublime.active_window().active_view().run_command('open_new_view_bug_test')

I see one dot, on one line. I expect three on three lines.
Changing scope of the first region to something invalid (like ‘foo’) makes the dot show up but obviously not with the color I want.

Sublime 3.3062 Windows

EDIT: Updated bug testcase incorporating facelessuser changes.

0 Likes

#2

IT would be nice to add an issue about this… github.com/SublimeText/Issues/i … state=open

This is not the first time someone reports this.

0 Likes

#3

The logic you used is flawed, I fixed it below:

Some of my themes the “comment” color didn’t show up, but some themes it does. I think Sublime sometimes had issues when tinting with certain colors. But the dots show up in the correct place with the alteration below. The first one didn’t always appear visible because of a tinting issue, but if you use a different theme, you will see the dot is there.

[code]import sublime
import sublime_plugin

class OpenNewViewBugTestCommand(sublime_plugin.TextCommand):
def run(self, edit):
new_view = self.view.window().new_file()
new_view.insert(
edit,
0,
‘There should be three different coloured dots in the gutter.\n’
‘\na\nb\nc\n’)
lines_regions = new_view.lines(sublime.Region(0, new_view.size()))
new_view.add_regions(‘region1’,
[lines_regions[2]],
scope=‘comment’,
icon=‘circle’,
flags=sublime.HIDDEN)
new_view.add_regions(‘region2’,
[lines_regions[3]],
scope=‘markup.inserted.diff’,
icon=‘circle’,
flags=sublime.HIDDEN)
new_view.add_regions(‘region3’,
[lines_regions[4]],
scope=‘markup.deleted.diff’,
icon=‘circle’,
flags=sublime.HIDDEN)[/code]

0 Likes

#4

@facelessuser: As far as I can see, you’ve just increased the indexes when getting regions from lines_regions. While indeed my example was flawed in the sense that it would not show the dots next to ‘a’, ‘b’, ‘c’ letters, that was not really the point of this bug. The point is that either one or more dots randomly fail to render.

The ‘comment’ scope I would expect to always render because all themes have (should have!) this scope defined.
And if that scope would consistently not render then I could maybe understand that there is some reason to it but it’s random from start to start of Sublime.

I’ll try to report this bug.

0 Likes

#5

This image shows results of trying the plugin in two different sessions. Once I even got all three to show up.
imgur.com/Gcq3RpC

0 Likes

#6

I understand. I was narrowing down the actual issue.

  • One of you marks was not showing up because you were targeting a zero width region (61, 61). There is an option in the API to make zero width regions show up. So that one was not an issue. So the indexing was important.
  • The tinting with ‘comments’ appears to be the only issue, and exists only on certain themes, though I don’t think this issue just exists with the “comment” scope, but is probably exposed by the comment scope on some themes.

That was my point. I use the gutter in a number of my plugins with no issues whatsoever. I find the comment issue interesting and the only relevant one I see. I am sure this relates to more than just comments, but it is exposed by comments. Maybe when a color is too close to the background color there is a problem. Maybe this problem only occurs on dark themes. If you use made up scopes, all the dots appear because no tinting actually occurs. So I think the issue is a tinting problem in sublime.

Anyways, just trying to help narrow it down. I wasn’t trying to insult your test. I probably should have elaborated more…

0 Likes

#7

Possibly the reason for the bug is tinting but comment scope doesn’t seem to be any special in regards to this bug. As I’ve written, I can make different scope icons fail between restarts of Sublime, using same theme.

(I did not take your comment as an insult at all. I’m also here just to make the issue as clear as possible.)

0 Likes

#8

You are correct. I am on a different system now, and I am not getting the same results I was last night. But switching themes makes certain one’s appear or disappear.

This is what I noticed:

  • Using a non-existent scope, the dots always appear I think the default foreground tint gets used in this case and appears to be pretty reliable.
  • Using other scopes, sometimes you see them sometimes you don’t depending on what scope you use and what theme you load.
  • If you don’t see a gutter icon, switching the theme may make some or all appear.

Some plugins you never notice an issue with gutter icons. I have a number of plugins that use icons where I configure custom scopes and all works fine. If I run your test with my custom scopes, the test runs fine. If I run with your scopes, it all goes to crap.

So, I think it is definitely a tinting issue, but now I think it is much more serious than I thought.

0 Likes

#9

github.com/SublimeText/Issues/issues/315

0 Likes

#10

Thank you!

0 Likes