GitGutter icon indicating copy to clipboard operation
GitGutter copied to clipboard

Bookmark icon is covered by Gutter

Open tiye opened this issue 13 years ago • 44 comments

Might be not really a bug though,.. If I try adding bookmark in the same line where Gutter highlights, there would be no response of bookmarks. I suppose the space at a line start can only hold one icon. While there are two, they just conflct. Then there's a problem: I can't tell from the line wether there's a bookmark, that's annoying.

tiye avatar Mar 21 '13 06:03 tiye

I hit this as well. Would love it if bookmarks would appear instead of git gutter marks.

lorin avatar Jul 05 '13 18:07 lorin

Thanks for brining this up, I never noticed because I have never used bookmarks before. I am not sure if there is a way to determine if a specific line already has an associated region (icon), or a way to get the key of such region.

If there is, then I could add a setting to GitGutter that allows you to specify which regions not to overwrite. (e.g. bookmark, bracket-highlights, etc.)

I took a glance at the API and all I see is the View.get_regions(key) method. I will have to experiment to see if I can use the keys set in a setting to determine if a specific line has a region for that key, and if so not to mark it.

jisaacks avatar Jul 05 '13 20:07 jisaacks

I just notcied the original issue was reported months ago. I guess it just wasn't on my radar until it just got the bump by @lorin

jisaacks avatar Jul 05 '13 20:07 jisaacks

I am getting hit by this and the Linter issue #113 also. Can the gutter be made wider?

ZenithDK avatar Sep 28 '13 14:09 ZenithDK

I'm pretty sure this is a Sublime Text issue/limitation. i.e there can be only 1 icon there at a time.

DisposaBoy avatar Sep 28 '13 14:09 DisposaBoy

~~That sounds rather weird, but for some reason prefixing all icon files with, say, "icon_" (and changing icon_path method accordingly) fixes the original issue. =~~

P.S.: Sublime Text 3, build 3054

P.P.S.: Sorry, it doesn't seem to be a robust fix, only some random types of mark gets covered with a bookmark. Still can't understand which and when exactly.

abusalimov avatar Nov 07 '13 22:11 abusalimov

@abusalimov I have no idea what you are talking about

on a side note: The possible solution I referred to a while ago, I have tested and confirmed it would work. However you would have to specify what regions were protected for GitGutter to not override them. Then anytime GitGutter is about to add an icon, it would have to grab all the regions for all the protected regions (each protected region could have many regions of that type on the screen) and make sure that non of them occupy the space that GitGutter wants to put an icon. I am afraid of this slowing GitGutter down, so I am not sure if this is a feature I want to add. It may only be useful in non blocking mode, which is only available in ST3.

Also the OP states:

I can't tell from the line wether there's a bookmark, that's annoying.

If you told GitGutter to not override then specific regions you would have the reversed problem:

I can't tell from the line wether there's a change, that's annoying.

So again, not sure if this feature is worth it.

jisaacks avatar Nov 07 '13 22:11 jisaacks

@jisaacks I don't think this would slow down GitGutter. All you need is to create a set of protected positions (beginnings of bookmarked lines) and check whether a position to be added is not in the set. Not a big deal for few regions types ("bookmarks", "mark", ...). Proof-of-concept: https://gist.github.com/abusalimov/7363673

I don't insist that this is a show-stopper thing. But personally I have both VcsGutter and GitGutter disabled only because they break my daily workflow making bookmarks unusable. Again, I understand that many developers dont't bother when bookmarks get hidden or don't use bookmarks at all.

P.S. It's a pity that Sublime can't combine two png images using their alpha channels. That would completely solve the issue without tricky hacks.

abusalimov avatar Nov 07 '13 23:11 abusalimov

I can't tell from the line wether there's a bookmark, that's annoying.

If you told GitGutter to not override then specific regions you would have the reversed problem.

For what it's worth, I'd prefer bookmarks to take precedence over git gutter markings, since it's easier for me to toggle a bookmark off to check if there's a git gutter marking (the bookmark keyboard shortcut is in my muscle memory) than vice versa.

lorin avatar Nov 08 '13 01:11 lorin

@abusalimov I understand the logic required to make this work, I have a working branch locally with the functionality. And in my code as in your gist (in the lines_of_regions method) it requires a nested for loop.

Lets say the user has specified 30 protected regions (they could easily if using SublimeLinter and BracketHighlighter) and lets says each protected region type has 5 actual regions by that name on the view.

That would be 150 calls to lines.update(line.begin() for line in self.view.lines(region)) just to check if it is OK to place an icon. And it would need to do this for every keystroke if using live mode.

I am not saying no to this feature, but these are the things that affect the decision. I may just add the feature with a warning that I recommend only using this feature in non blocking mode (which is ST3 only.)


@lorin I have also considered a toggle for git gutter to clear the icons, that would allow you to toggle back and forth between viewing git_gutter/bookmarks/whatever

jisaacks avatar Nov 08 '13 21:11 jisaacks

@jisaacks well, you are talking about the most general solution where the user could specify a list of protected regions. I'm sure that with resonable defaults provided (like with only bookmarks and marks taking precedence) and a warning about adding more region types this feature would be perfectly fine. After all, I'm pretty sure that counting even 1500 markers would be still faster than getting a fresh diff each time (which forks a subprocess for that). Anyway, the final decision is up to you, of course.

abusalimov avatar Nov 08 '13 23:11 abusalimov

@abusalimov I added a branch called protected-regions it defaults to no protected regions so you would need to specify any you want to protect in your user settings. Please check it out and let me know your thoughts.

jisaacks avatar Nov 09 '13 22:11 jisaacks

@jisaacks thank you.

I can see that in your solution you read a setting and collect protected regions for every single line of the resulting diff which in turn can be rather big. I don't think that having lots of protected regions is real (see my previous comments), but I believe that there can be a huge diff with thousands lines. And that can really hurt the performance.

In the solution that I've suggested above you only need to prepare a set of protected regions once. After that a simple set lookup (which is really fast in Python) is performed for each diff line to be marked.

abusalimov avatar Nov 09 '13 23:11 abusalimov

@abusalimov

for every single line of the resulting diff

Not exactly, just for every line that has changed and GitGutter wants to place an icon on. But either way, you are still correct, better to only calculate it once.

Would you like to make a pull request with your version?

jisaacks avatar Nov 10 '13 00:11 jisaacks

@jisaacks well, I'm new to github, and I'm afraid I'll get some free time to learn it only on the next weekend. So if this change is not too urgent, I could do it within a week.

I also noticed that in my solution (I guess, in your too) there is a little bug: when removing a bookmark on a changed line this line would have no mark at all (because changed mark was not added because of the bookmark). May be you know, is there any hook to intercept changes on certain regions?

abusalimov avatar Nov 10 '13 00:11 abusalimov

@abusalimov well in the case of boomarks you can listen for text commands via the on_text_command sublime text event listener and check the command name to see if it contains the string bookmark. That doesn't solve the general problem though.

It would be nice if in the method where we are checking for protected regions, if a protected region is found, place an event listener on the region for when it gets cleared. I don't think that is possible.

I'll keep thinking about it and see if I can come up with any clever ideas.

jisaacks avatar Nov 10 '13 01:11 jisaacks

@jisaacks, I've just forked the repo. Should I commit into the protected-regions branch (maybe overriding changes you already made) or into the master?

abusalimov avatar Nov 18 '13 00:11 abusalimov

Lets keep this feature in the protected-regions branch for now.

jisaacks avatar Nov 18 '13 03:11 jisaacks

+1 here. Is the current status still in protected-regisions branch?

sundarv85 avatar Nov 06 '15 11:11 sundarv85

I merged the protected-regions branch into master. However, I am trying to get people to test it out and report back to me (using GitGutter-EDGE) before I cut a release. Unfortunately, I haven't had a report of a single user installing and using protected-regions.

jisaacks avatar Nov 06 '15 16:11 jisaacks