Skip to content
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

Support diff highlight with original file format syntax scheme #961

Open
asfaltboy opened this issue Jun 27, 2018 · 11 comments
Open

Support diff highlight with original file format syntax scheme #961

asfaltboy opened this issue Jun 27, 2018 · 11 comments

Comments

@asfaltboy
Copy link
Member

This might be dupe, if so I appologize; I saw the discussion being had a number of times, but never as a proper feature request, so here we go.

In Github the diff with highlight is displayed very nicely, and I'd like to have it in sublime.

I know this can be done, but not sure how cleanly the code will remain after. The plugin sublime-compare-side-by-side does this by applying "highlight" to files that have been added to the view with the original/default syntax scheme. I understand that with side-by-side diff it is easier to keep syntax, and in "patch view" case we might need to apply the syntax line by line (by checking the original file's syntax for the row) + apply the diff highlight.

Related tickets, discussions:
#666
8c1313b#r121255619

@randy3k
Copy link
Collaborator

randy3k commented Jun 30, 2018

Actually, I tried the approach of applying the syntax line by line in the blame view, but it was incredibly slow and I had to abandon that.

@stoivo
Copy link
Member

stoivo commented Jun 30, 2018

Have you tried to do it only for the content vissable? I think sublimes has an API for checking the viewport. Or is it slow on small files as well

@randy3k
Copy link
Collaborator

randy3k commented Jun 30, 2018

It is ok for small files, but it is an O(n) operation.

@stoivo
Copy link
Member

stoivo commented Jun 30, 2018

And did you look at the option for only doing it for the current virwport?

@randy3k
Copy link
Collaborator

randy3k commented Jul 1, 2018

No. I am not sure if sublime has an event listener on change of viewport.

@asfaltboy
Copy link
Member Author

We might be able to get the syntax for the whole file then, by using the "open, get syntax and close quickly" method. To avoid continuous flicker, we can also "cache" the syntax for each opened file, as described here: https://forum.sublimetext.com/t/get-syntax-associated-with-file-extension/26348/11

@asfaltboy
Copy link
Member Author

There's also a discussion on a relevant feature request in sublimehq/sublime_text#2312, and a workaround provided by sublime_lib here.

@kaste
Copy link
Collaborator

kaste commented Nov 11, 2019

@randy3k How did you apply the syntax line-by-line? Applying foreground regions token by token? Which tokenizer did you use?

@randy3k
Copy link
Collaborator

randy3k commented Nov 11, 2019

I used view.scope_name to extract the scopes from an ordinary view of the file and then use view.add_regions to apply the scopes to the blame view. It was quite slow for files > 1000 lines.

@asfaltboy
Copy link
Member Author

Do you still have that branch? Maybe we can hack around it?

@randy3k
Copy link
Collaborator

randy3k commented Nov 17, 2019

I have discarded that unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants