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

Syntax highlighting for JSM #5250

Merged
merged 1 commit into from Aug 1, 2018

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Jul 31, 2018

Fixes #2155

Changes proposed in this pull request:

  • Add syntax highlighting for .jsm files

What did I do to test the code and ensure quality:

  • Manual testing

Has been tested on:

  • GIT 2.18
  • Windows 10

private static readonly Lazy<Dictionary<string, Regex>> _regexes = new Lazy<Dictionary<string, Regex>>(ParseRegexes);
#pragma warning disable VSTHRD012 // Provide JoinableTaskFactory where allowed
private static readonly AsyncLazy<Dictionary<string, Regex>> _regexByExtension = new AsyncLazy<Dictionary<string, Regex>>(ParseRegexesAsync);
#pragma warning restore VSTHRD012 // Provide JoinableTaskFactory where allowed
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell could you verify that this diagnostic can be skipped in this scenario? The async operation only awaits disk IO operations so as I see it there's no opportunity for deadlock.

Getting a JTF in this static initialiser is awkward. We'd likely need a new Initialise instance method, or convert the ctor to a static factory.

@codecov
Copy link

codecov bot commented Jul 31, 2018

Codecov Report

Merging #5250 into master will decrease coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5250      +/-   ##
==========================================
- Coverage   35.95%   35.95%   -0.01%     
==========================================
  Files         587      587              
  Lines       45179    45179              
  Branches     6205     6205              
==========================================
- Hits        16243    16242       -1     
  Misses      28181    28181              
- Partials      755      756       +1

var regex = GetRegexForExtension(Path.GetExtension(file.Name));
var extension = Path.GetExtension(file.Name);

var regexByExtension = await _regexByExtension.GetValueAsync(cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be async?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous code parsed file synchronously during the first call to Lazy<Dictionary<...>>.Value. That happend during show of FormCommit, which would block during IO, reading the file.

This change uses AsyncLazy which allows the factory function to be async, which allows async IO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably initiate this process when we start the app, and thus won't need such complex structure, can probably replace it with ConcurrentDictionary...
thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do. It's not a big saving here anyway as the file is small and fast to read. On the order of a few milliseconds in my testing with an SSD. I mostly wanted to experiment a little more with vs-threading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to drop the second commit from this PR.

Copy link
Member

@RussKie RussKie Jul 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KISS, if we can help it :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep It SynchronouS ? ;)

@drewnoakes drewnoakes changed the title Syntax highlighting for JSM and non-blocking completion regex loading Syntax highlighting for JSM Jul 31, 2018
@drewnoakes
Copy link
Member Author

Peeled the last commit off.

@vbjay
Copy link
Contributor

vbjay commented Jul 31, 2018 via email

@RussKie
Copy link
Member

RussKie commented Jul 31, 2018 via email

@RussKie RussKie merged commit f506369 into gitextensions:master Aug 1, 2018
@RussKie RussKie added this to the 3.00 milestone Aug 1, 2018
@drewnoakes drewnoakes deleted the fix-2155-jsm-syntax branch August 1, 2018 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants