Frederisk / Wikitext-VSCode-Extension

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

Treat `|}` as table closure only at start of line #78

Closed jwfxpr closed 1 year ago

jwfxpr commented 1 year ago

Currently, the bracket highlighting treats |} as a special digraph, which is appropriate when handling tables. Wikitext tables are demarked by an opening {| and closing |}, which must be at the start of a line to be interpreted as a table.

These two characters also appear frequently in non-lua template code, especially when handling parameters in parser functions. E.g.,

{{#if:{{{1|}}}|First unnamed parameter has a value|First unnamed parameter has no value}}

This example evaluates to First unnamed parameter has no value if the first unnamed parameter has no value.

Currently, the extension will sometimes incorrectly interpret the |} here as a table closure, leading to incorrect and confusing bracket matching in templates which use this technique:

image

The more complex the template, the more this error compounds, leading the extension to be counterproductive when handling the most complex templates (which is where it should be most relied upon).

Restricting the |} table closure symbol matching to the start of a line would eliminate this issue. 😊

Frederisk commented 1 year ago

I'm not sure what version of the extension is running on your device, but the problem didn't happen on mine. By the way, the latest version now publicly available is v3.8.0.

image

... which must be at the start of a line to be interpreted as a table.

This has been done a long time ago.

jwfxpr commented 1 year ago

This is on the latest released version, 3.8.0. The screenshot snippet above is from that version.

image

I have since noticed that this behaviour only seems to occur when wikitext is pasted into an open buffer, rather than when a file on disk is opened, or the text is typed in. This is my main workflow for using this extension: Copy-paste wiki source into the editor, work on it, copy-paste it back to the wiki interface, save.

Frederisk commented 1 year ago

It's weird. I'm using the Insiders v1.79.0 of VSCode, and I can't reproduce this issue. This looks more like some sort of issue with VSCode.

jwfxpr commented 1 year ago

Oh that's interesting. I'm using the current stable vscode, 1.78.2.

I guess we wait and see if the 1.79 fixes the behaviour. I'll try to update this issue then either way, with a much more definite reproducable example if necessary. 😊

Thanks for taking the time to look into it!

jwfxpr commented 1 year ago

With a little further investigation, I've tracked this down to an unexpected interaction with another extension! Sorry for the confusion and thanks again for the time spent.