godotengine / godot

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

Evaluate selection (Ctrl+Shift+E) does not parse underscores #97324

Open Cykyrios opened 2 weeks ago

Cykyrios commented 2 weeks ago

Tested versions

v4.3.1.rc.custom_build [d40fc50f0] 4.4 on latest master

System information

Godot v4.3.1.rc (d40fc50f0) - Manjaro Linux #1 SMP PREEMPT_DYNAMIC Wed Aug 7 16:19:28 UTC 2024 - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7900 XT (RADV NAVI31) - AMD Ryzen 9 7900X 12-Core Processor (24 Threads)

Issue description

In the script editor, selecting an expression and pressing the shortcut for Evaluate Selection does just what the name suggests, e.g. selecting 10+24 will transform the selection into 34. However, for larger numbers, or any number where you put underscores for readability, e.g. 500+10_000, all characters starting from the underscore are ignored, which results in 510 instead of 10500.

Steps to reproduce

Minimal reproduction project (MRP)

N/A

AThousandShips commented 2 weeks ago

This is a limitation in the way this class parses things, it's very basic, in the same way "1_000".is_valid_int() returns false, and that's where things would need to be improved for this to work

But this is quite an advanced part of formatting

Will make a PR to document the fact that the string methods do not support this formatting

HolonProduction commented 2 weeks ago

Worth noting that #97218 uses the expression parser as well, so it will be effected by this as well.