Skip to content

Text block breaks syntax highlighting if an odd number (>=3) of double quotes appear inside the text block #1264

Closed

Description

@anthonyvdotbe

As soon as a text block contains an odd number (>=3) of double quotes, the rest of the file is colored as if it were part of the text block (but there's no compilation errors & things like autocompletion etc. work, it's just syntax highlighting that breaks).

Environment
  • Operating System: Windows 10
  • JDK version: 13.0.1
  • Visual Studio Code version: 1.42.0
  • Java extension version: 0.55.1
Steps To Reproduce
  1. Create a Java file with a text block that contains 3 double quotes, e.g.
class Foo {

    private static final String BAR = """
        1"
        2"
        3"
        """;

    private static void baz() {}

}
Current Result

Notice how the baz method etc. are fully orange.
image

Expected Result

Syntax highlighting is correct.

Activity

  1. changed the title [-]Text block breaks syntax highlighting as soon as 3 quotes appear inside the text block[/-] [+]Text block breaks syntax highlighting if an odd number (>=3) of double quotes appear inside the text block[/+] on Feb 9, 2020
  2. akaroml commented on Feb 17, 2020

    @akaroml
    Contributor

    @Vigilans did you merge the syntax highlighting PRs from Atom to VS Code?

    And please let us know if this bug is fixed by any of your PRs.

  3. JoseLion commented on Oct 8, 2021

    @JoseLion

    It seems this is still an issue on v0.82.0. Any news around this? 🙂

    image

  4. JoseLion commented on Oct 8, 2021

    @JoseLion

    Also, it'd be great if the \ (line-terminator) character could be highlighted too, so it's not confused with text inside the block. Of course, I think that has nothing to do with this specific issue, so I can open a separate ticket for that if it makes sense 🙂

  5. dropofwill commented on May 18, 2022

    @dropofwill

    Line-terminator seems to cause the same issue, e.g.:

        class Foo {
            private static final String BAR = """
                    1 \
                    2 
                    3 
                    """;
    
            private static void baz() {
            }
        }
    
  6. Eskibear commented on May 23, 2022

    @Eskibear
    Contributor

    (originally reported by @jflorez-planittesting)

    Environment:

    • VS Code Version: 1.67.0
    • Java Extension Pack Version: 0.22.4
    • JDK Type & Version: openjdk version "17.0.2" 2022-01-18
    • OS Type & Version: macos 12.3.1 (21E258)

    Step to Reproduce:
    create a text block with a json inside it, add a http URL to a JSON value
    image

    Expected Behavior:
    Syntax highlighting is unaffected

    Actual Behavior:
    Syntax highlighting inside the text block and in subsequent Java code is altered and colours deviate from the configured theme

  7. pangoleaf commented on Oct 25, 2022

    @pangoleaf

    I've just come across the same issue as with the post by @Eskibear above.

    I think, if possible, at a basic level all double quotes inside triple quotes blocks should be treated as automatically escaped as that's how the compiler sees it.

  8. GustavoASC commented on Mar 17, 2023

    @GustavoASC

    I am also facing this same issue

  9. Kamilake commented on Apr 20, 2023

    @Kamilake

    image
    I can't believe there hasn't been any news here in three years.

  10. hopehadfield commented on Jul 25, 2023

    @hopehadfield
    Member

    All issues regarding syntax highlighting in text blocks have been fixed via #3200.

    Before:
    Screenshot from 2023-07-12 14-44-21

    After:
    Screenshot from 2023-07-12 14-42-27

    Closing as completed.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions