redhat-developer / quarkus-ls

Language server for Quarkus tooling
Eclipse Public License 2.0
43 stars 15 forks source link

Completion should generate only start section when empty end section is found #807

Closed angelozerr closed 1 year ago

angelozerr commented 1 year ago

Generate only start section when empty end section is foundCompletion should generate only start section when empty end section is found

Fixes #805

Signed-off-by: azerr azerr@redhat.com

angelozerr commented 1 year ago

@JessicaJHee here a new PR which do the samething than PR https://github.com/redhat-developer/quarkus-ls/pull/806 but without updating end tag section (since {/} is a valid end section). Here a demo:

SnippetCompletionOnStartTag

angelozerr commented 1 year ago

The code of this PT should be clean, you can review it.

datho7561 commented 1 year ago

If you have an unnamed close tag right after what you're writing, then it will never generate a close tag for tag completion, even if there aren't enough unnamed close tags to match the content you are generating:

DoesntGenerateCloseTag

angelozerr commented 1 year ago

If you have an unnamed close tag right after what you're writing, then it will never generate a close tag for tag completion, even if there aren't enough unnamed close tags to match the content you are generating:

I have improved template parser to take care of this usecase. Please retry it.

angelozerr commented 1 year ago

@JessicaJHee could you check if it is working with surround please.

datho7561 commented 1 year ago

Given the following template:


|{#each items}

{#each items}
  {it.name}
{/each}

{#each items}

{#each items}
  {it.name}
{/each}

{/}|

If I select between the two |, then I get a lot of code action failure notifications

angelozerr commented 1 year ago

According this comment it is not a good idea to change the behavior of the parser.

I revert my change and to fix the original issue

{#each items}
    {#|}
{/}

which didn't generate the full content of the snippet (only the first part of the section), I check if parent section of {# is closed. In this case, #each is not closed because the {/} is linked to {#. As parent section of {# (which is the #each) is not closed, the full content of the snippet must be generated.

@datho7561 please retry it and I suggest that you get https://github.com/redhat-developer/vscode-quarkus/pull/585 to play with surround too.

angelozerr commented 1 year ago

Here a demo:

SurroundSection

datho7561 commented 1 year ago

Seems pretty good so far, I'm going to try it out with https://github.com/redhat-developer/vscode-quarkus/pull/585 and see how that goes...