godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.71k stars 20.12k forks source link

In code comments, single or double quote inside pair of brackets breaks bracket matching, showing brackets in red when near caret #94512

Open hsandt opened 1 month ago

hsandt commented 1 month ago

Tested versions

System information

Godot v4.2.1.stable - Ubuntu 22.04.4 LTS 22.04 - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 860M (nvidia; 535.161.07) - Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 Threads)

Issue description

If you write: # ('), or spanned on multiple lines:

# ('
# )

And you move the caret near the brackets, you'll see that they will appear highlighted in red, showing that they are no matching brackets, instead of underlining their match. This is because a closing quote is expected, as in code. In fact, closing the quote with a second quote of the same type will fix the issue.

However, this commonly happens in English and other languages using quotes:

# (We're unsure about this line)

and the quote themselves do not benefit from quote matching: placing the caret near them does not highlight any matching quote, e.g. in:

# (print 'hello')

so there is not much use is considering quotes as string delimiters in comments. We may just ignore them and focus on matching brackets instead.

This aslo applies to double quotes " and square brackets [], as well as export tooltip comments ##.

Steps to reproduce

Write comment:

# (')

or multiline:

# ('
# )

then move caret near a bracket, on its external side (left or opening bracket, right or closing bracket): instead of underlining matching bracket, only that bracket highlighted in red.

Add a closing quote and see how it fixes the issue.

Minimal reproduction project (MRP)

N/A

AThousandShips commented 1 month ago

Can you test in 4.2.2? Just to make sure

HolonProduction commented 1 month ago

Can reproduce in v4.3.beta.custom_build [da4f6e439]

For the multi line case only the second quote is displayed red. The first one matches with the second one just fine.

jsjtxietian commented 1 month ago

Looks like ImmediateMesh should have a way to inform the mesh instance to be dirty, but it's mesh->instances is empty.

hsandt commented 1 month ago

Reproduced in v4.3.rc2.official [3978628c6]