pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.33k stars 140 forks source link

[modern-tree-sitter] Java Syntax Highlighting #896

Closed confused-Techie closed 9 months ago

confused-Techie commented 9 months ago

Thanks in advance for your bug report!

What happened?

I've noticed what feels like a bug in Java Syntax Highlighting.

Which to be clear is way better in Java, although still seems to be missing something.

In the following snippet:

import java.util.Scanner;

public class balloon {
  public static void main(String[] args) {
    int initialDiameter;
    Scanner scnr = new Scanner(System.in);
    System.out.print("Input Initial Diameter: ");
    initialDiameter = scnr.nextInt();

    int diameter = initialDiameter;

    double v1 = Math.PI * initialDiameter * initialDiameter * initialDiameter / 6;

    diameter = diameter++;

  }
}

In this snippet the diameter = diameter++; only applies highlighting on the = with the rest being just basic text.

Additionally, the assignment of initialDiameter is blank, along with usage of initialDiameter later on, although thats less of an issue.

To be clear, non of this is a regression, in fact in the Legacy Tree-Sitter the situation is the same, except two things:

So mostly things are better here, but still not perfect.

Would love if you could take a look!

Pulsar version

1.113.0

Which OS does this happen on?

🪟 Windows

OS details

2H22

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

  1. Create file anthing.java
  2. Paste above code snippet in
  3. View the lack of highlighting

Additional Information:

No response

savetheclocktower commented 9 months ago

Addressed in this commit. Should now scope variables whenever they're reassigned or incremented. Also added -- and ++ as operators.

confused-Techie commented 9 months ago

Amazingly speedy @savetheclocktower, absolutely unbelievable, thanks!