Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double clicking on a word can select prior not character symbol #69254

Open
bsil78 opened this issue Nov 27, 2022 · 9 comments · May be fixed by #92514
Open

Double clicking on a word can select prior not character symbol #69254

bsil78 opened this issue Nov 27, 2022 · 9 comments · May be fixed by #92514

Comments

@bsil78
Copy link

bsil78 commented Nov 27, 2022

Godot version

4.0-beta6

System information

Windows 10

Issue description

Word selection is not stopping to some symbols on left of word (tested +=>$) if prior symbol of this character is not a word or spacing character which is not very practical for most of them ; no problem with ,!-<%;* however.

It seems to be right too in Label and RichTextLabel text edit box... but there rules could be different ?

I tested too €uro, ₩on, ¥en as examples, but those characters arez similar to letters and I am less anoyed to see them selected...

Steps to reproduce

Just open any script, exit any Label or RichTextLabel text and type examples below,
then double-click on word in order to select it :

  • "var1==var2" : if I double-click on var2, =var2 is selected
  • "func myFunc()->int:" : if I double-click on int, >int is selected
  • "this is test for ++tag" : if I double-click on tag, +tag is selected

Minimal reproduction project

Any project, in any script or Label text edit box, or RighTextLabel text edit box

@bsil78
Copy link
Author

bsil78 commented Nov 27, 2022

I searched for similar issue with :
is:issue is:open label:bug label:topic:editor word selection

And only one related I found was a graphical issue :
#55588

@bsil78
Copy link
Author

bsil78 commented Nov 27, 2022

Found #56402 which is similar but restricted to $

@bsil78
Copy link
Author

bsil78 commented Nov 27, 2022

I found that putting space before things is an acceptable workaround ;
what bothered me was difference of behavior for different symbols...

@bsil78
Copy link
Author

bsil78 commented Nov 27, 2022

In fact I was chocked because Godot 3.5.x do not behave like that... it feels like some regression to me.

@Calinou
Copy link
Member

Calinou commented Dec 1, 2022

You can change the list of non-word characters for the purpose of text navigation/selection in the Editor Settings, but I agree the default value should be changed to get the 3.x behavior back. Feel free to open a pull request for this 🙂

@clayjohn clayjohn modified the milestones: 4.0, 4.x Jan 26, 2023
@akien-mga akien-mga modified the milestones: 4.x, 4.1 Feb 13, 2023
@pattlebass
Copy link
Contributor

You can change the list of non-word characters for the purpose of text navigation/selection in the Editor Settings, but I agree the default value should be changed to get the 3.x behavior back. Feel free to open a pull request for this 🙂

I can't find any setting.

This seems to be caused by TextServerAdvanced's u_ispunct() which doesn't consider certain characters as punctuation. Using TextServerFallback matches the 3.x behavior because it uses Godot's is_punct().

A way to solve this would be to add custom_punctuation to CodeEdit.
Also, we should maybe match is_punct()'s behavior with u_ispunct().

Differences between the two functions:

Code Char u_ispunct() is_punct() Diff
32 0 1 *
33 ! 1 1
34 " 1 1
35 # 1 1
36 $ 0 1 *
37 % 1 1
38 & 1 1
39 ' 1 1
40 ( 1 1
41 ) 1 1
42 * 1 1
43 + 0 1 *
44 , 1 1
45 - 1 1
46 . 1 1
47 / 1 1
48 0 0 0
49 1 0 0
50 2 0 0
51 3 0 0
52 4 0 0
53 5 0 0
54 6 0 0
55 7 0 0
56 8 0 0
57 9 0 0
58 : 1 1
59 ; 1 1
60 < 0 1 *
61 = 0 1 *
62 > 0 1 *
63 ? 1 1
64 @ 1 1
65 A 0 0
66 B 0 0
67 C 0 0
68 D 0 0
69 E 0 0
70 F 0 0
71 G 0 0
72 H 0 0
73 I 0 0
74 J 0 0
75 K 0 0
76 L 0 0
77 M 0 0
78 N 0 0
79 O 0 0
80 P 0 0
81 Q 0 0
82 R 0 0
83 S 0 0
84 T 0 0
85 U 0 0
86 V 0 0
87 W 0 0
88 X 0 0
89 Y 0 0
90 Z 0 0
91 [ 1 1
92 \ 1 1
93 ] 1 1
94 ^ 0 1 *
95 _ 1 0 *
96 ` 0 1 *
97 a 0 0
98 b 0 0
99 c 0 0
100 d 0 0
101 e 0 0
102 f 0 0
103 g 0 0
104 h 0 0
105 i 0 0
106 j 0 0
107 k 0 0
108 l 0 0
109 m 0 0
110 n 0 0
111 o 0 0
112 p 0 0
113 q 0 0
114 r 0 0
115 s 0 0
116 t 0 0
117 u 0 0
118 v 0 0
119 w 0 0
120 x 0 0
121 y 0 0
122 z 0 0
123 { 1 1
124 | 0 1 *
125 } 1 1
126 ~ 0 1 *
127 0 0

@vfig
Copy link

vfig commented May 30, 2023

This also affects using ctrl+left/ctrl+shift+left/ctrl+backspace to move/select/delete the word to the left.

On more than one occasion, this has introduced a bug: an inadvertent change of a foo>=bar comparison into foo>qux when I edited the variable name on the right hand side.

(And on many occasions it has caused a foo==bar to be inadvertently changed to foo=qux, but at least this one is caught by assignment being disallowed in expressions in GDScript.)

In addition, presumably due the same cause, there is a discrepancy when editing GDScript code between $Node, where the caret/selection is placed before the $ versus %Node, where the caret/selection is placed after the %.

@akien-mga akien-mga changed the title [4.0] double clicking on a word can select pior not character symbol Double clicking on a word can select prior not character symbol Jun 22, 2023
@akien-mga akien-mga modified the milestones: 4.1, 4.x Jun 22, 2023
@akien-mga
Copy link
Member

CC @bruvzg

@bsil78
Copy link
Author

bsil78 commented Nov 7, 2023

(4.2 beta5 tests)

As I can see, most work properly but when there is several ponctuation characters before selection ; exemples :
a==b => (same if first = is + or - instead) double-clicking b willl select =b, a=b is fine though as it select only b then
func(arg)->void; => double-clicking void willl select >void, func(arg) -> void is fine though as it select only void then
print("test >>word") => (notice the space) double-clicking word willl select >>word ; but should select only word
print("test>>word") => (notice no space) double-clicking word willl select >word ; but should select only word

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

Successfully merging a pull request may close this issue.

6 participants