-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Improve CodeEdit
's toggle comments behavior
#44557
Conversation
From memory is_line_comment includes slash because it is used for the shader editor too which uses c-style comments. I think @Paulb23 is still working on a rewrite and reorganisation of TextEdit which should move some of this functionality out of TextEdit |
I think ok solution would be to create function in I can also create separate function just for my usage but It duplicates very similar logic. Either solution is simple, not sure which one to use since some rewrite is underway, maybe if @Paulb23 or other maintainer will decide to review this feature they will advise. |
Sorry did not see your comment. I will try to make rebase and work on this issue this week |
3918735
to
36dc42f
Compare
7fcfef3
to
084da69
Compare
I've done it - toggling comments now respects indentation which solves godotengine/godot-proposals#110 - but I forgot about new comment api :D, will take a look at it and update this PR in near future. |
@iwek7 Do you still plan to work on this? |
CodeEdit
's toggle comments behavior
Hi, I kind of forgot about this issue. I will check code today and see if it is easy to incorporate Pauls proposal. |
084da69
to
c8e8e70
Compare
I've pushed some changes. I tried to use |
c8e8e70
to
8e41527
Compare
I've introduced minor selection regression, which is fixed by last addition to this pr. Now all looks good. |
for (int i = begin; i <= end; i++) { | ||
if (!text_editor->get_line(i).begins_with(delimiter)) { | ||
// `+ delimiter.length()` here because comment delimiter is not actually `in comment` so we check first character after it | ||
if (text_editor->is_in_comment(i, text_editor->get_first_non_whitespace_column(i) + delimiter.length()) == -1) { | ||
is_commented = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to also check the delimiter matches with get_delimiter_start_key
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this check here and in other branch of this if
as well, so that for instance shader code like
/* code... */
will have //
added at the beggining when toggled
8e41527
to
e3ed6db
Compare
I've applied requested changes, code is ready for review again |
@Paulb23 If you could take a look! |
0e7c6f3
to
97d7a1c
Compare
I've rebased it after multicaret changes, it is ready for review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for rebasing, lgtm!
Hey, sorry for the wait. Could you please rebase your PR? And while you do that, would be good to adjust the commit message to state that this is about CodeEdit. |
97d7a1c
to
b0df2e1
Compare
Code is rebased and ready for review again |
CodeEdit
's toggle comments behaviorCodeEdit
's toggle comments behavior
Thanks! |
Draft implementation for godotengine/godot-proposals#2005. Not sure if using is_line_comment method of
text_edit
is proper (it breaks if line begins with /) but I like idea of encapsulating idea of checking if line is comment intext_edit
- so I can either use this method or write new one.Maintainer edit: Closes godotengine/godot-proposals#110