GDQuest / learn-gdscript

Learn Godot's GDScript programming language from zero, right in your browser, for free.
https://gdquest.github.io/learn-gdscript/
Other
2.11k stars 160 forks source link

Practice exercise, code editor: second indentation added #221

Closed duianto closed 2 years ago

duianto commented 2 years ago

Describe the bug

An extra indentation is added in the practice exercise, code editor. When the expressions, but not the first indentation, are removed under a function header.

To Reproduce

Steps to reproduce the bug:

  1. Go to the first practice exercise in lesson 9: https://gdquest.github.io/learn-gdscript/#course/lesson-9-adding-and-subtracting/practice-nk1K416Q.tres
  2. Click at the end of the second line to place the cursor (shown as a vertical bar | below) after the word pass
    func take_damage(amount):
    pass|
  3. Press ctrl backspace to erase the word to the left.

Expected behavior

Only the text pass should be removed, without adding a second indentation.

func take_damage(amount):
    |

Observed

A second indentation was added.

func take_damage(amount):
        |

Information about your device (please complete the following information):

Additional context

The issue can be repeated by:

But the issue can't be reproduced after:

As demonstrated below, this issue isn't limited to pressing ctrl backspace.

The same thing happens when selecting the expressions, after the second line's indentation, to the end of the code editor's last line. And pressing backspace or delete. (see the examples below)

The issue isn't limited to the practice exercise in lesson 9. It probably happens in all exercises that use the code editor.

For example, in the first lesson: https://gdquest.github.io/learn-gdscript/#course/lesson-1-what-code-is-like/practice-55916.tres

func _ready() -> void:
    print("Welcome!")

Select: print("Welcome!") Press: backspace or delete The selected text was replaced with an extra indentation:

func _ready() -> void:
        |

It also happens in lesson 6, which has multiple lines in the function. https://gdquest.github.io/learn-gdscript/#course/lesson-6-multiple-function-parameters/practice-qAYVjotx.tres

func draw_corner():
    move_forward()
    turn_right(90)
    move_forward()

Select from the second line, after the first indentation, to the end of the last line:

Another example is to just leave a single indentation on the second line:

func draw_corner():
    |
NathanLovato commented 2 years ago

I think I know why this happens, I'll fix this a bit later