Frederisk / Wikitext-VSCode-Extension

A Visual Studio Code Extension that provides language support for Wikitext.
MIT License
89 stars 14 forks source link

Bracket highlighting not working in v3.7.0 #70

Closed DevarooGit closed 1 year ago

DevarooGit commented 1 year ago

G'day, thanks for this very useful extension. FYI, in v.3.7.0 bracket highlighting doesn't work at all on my machine. Nada, niente. In v.3.6.5 it works 99% fine; only issue is that highlighting of some closing brackets is delayed. I'm currently using the extension with VS Code 1.74.0 with macOS Catalina (10.15.7). If you need more information please let me know. Cheers, Lucas

Frederisk commented 1 year ago

Due to some API technical limitations, I can't control the correct rendering of bracket highlighting, so I disabled this feature in the latest version. I'm thinking of some other countermeasures to improve the problem.

Also, I've noticed that some themes may not render editor tokens correctly. But the default Dark+ theme is ok, if it doesn't have any highlight on some popular theme, please let me know.

DevarooGit commented 1 year ago

Righto, not surprising then that brackets don't highlight if that's been disabled! I sure hope that'll be back in future versions; at least for me, bracket highlighting is pretty much the most important feature, e.g. when writing complex templates (well, I should probably learn Lua and switch to Modules anyway :grimacing: but for now...). Anyway, I appreciate that those API limitations are currently in the way so no complains here. Re: themes, I only use the default dark theme, so no experience with others.

Frederisk commented 1 year ago

Another solution is to use the previous solution, adding highlighting to each parenthesis. I'm wondering if you think it's better to use a scheme like this as shown in the picture (which might make the display too fancy), or would you rather have no highlighting?

image

PS: Just an investigation and may not end up selecting these options.

shaedrich commented 1 year ago

Is this just about syntax highlighting in general, or about matching bracket pairs? Because, especially in wikitext where you can't have indention and stuff, I really need to find bracket pairs quickly in large templates.

Frederisk commented 1 year ago

Yes, I mean the matching of paired parentheses.

DevarooGit commented 1 year ago

Another solution is to use the previous solution, adding highlighting to each parenthesis. I'm wondering if you think it's better to use a scheme like this as shown in the picture (which might make the display too fancy), or would you rather have no highlighting?

No, highlighting single brackets isn't helpful. The ideal solution is something like this:

VS-Studio-Code-Wikitext-Bracket-Highlighting

This solution (1) matches double curly braces (templates) as well as triple curly braces (parameters) and (2) uses different colors if templates or paremeters are nested. Which happens to be what I get with Wikitext extension v3.6.5, running on VC 1.74.0 for macOS 10.15.7.

Frederisk commented 1 year ago

The problem is that such highlights will render incorrectly in many edge cases:

{{t|{{#if:|}}}}

image

Some people complain about wrong rendering like this.

DevarooGit commented 1 year ago

/offtopic start

Especially in wikitext where you can't have indention

If indentation is giving you trouble, I would recommend to still write clean code in VC Code – i.e., with appropriate line breaks and indents – and then save a copy with all line breaks and indents removed for use in MediaWiki. This can easily be done in VC Code by selecting all code and pressing ctrl+j (on mac, don't know what the Windows hotkey is). This is incredibly useful even when you have bracket highlighting. BTW, I've found that indentation actually does work well in most cases (MW 1.38 / 1.39); but yeah, there's the odd case where it doesn't work. In those cases I would use the method described above.

/offtopic end

DevarooGit commented 1 year ago

The problem is that such highlights will render incorrectly in many edge cases:

{{t|{{#if:|}}}}

This isn't really an edge case, it's simply a nested template where two or more closing brackets are right next to each other (i.e., without other characters between them). (In this case it's a parser function nested inside a template, but given that a parser function also has 2 curly brackets at its start and end, I assume that won't make a difference?).

Anyway, users can fix the issue that you show by adding a space between the closing brackets:

Screenshot 2023-01-08 at 13 40 43

Another way to fix this is adding line breaks before parameters:

Screenshot 2023-01-08 at 13 40 44

I've found that both solutions work well in most cases, i.e. they won't break wikitext functionality.

I would agree that not having to use such workaround would be even more convenient. But for me personally it's acceptable. Especially since using linebreaks is often the cleanest solution anyway (see my previous response to @shaedrich). In any case, using this very small workaround is imho preferable to not having bracket matching at all.

Frederisk commented 1 year ago

OK, I'll take your opinion. And try to restore this functionality in a future minor version update.

DevarooGit commented 1 year ago

Sounds good, thanks mate! If necessary, feel free to adapt my previous response for the documentation, e.g. for a section "Known issues". Greetings and have a nice evening