serenity icon indicating copy to clipboard operation
serenity copied to clipboard

TextDocument: auto-indentation issues

Open NonStandardModel opened this issue 4 years ago • 1 comments

Symptoms:

  1. In an empty line writing only space and than new-line (with cursor after space), the space will be moved to next line. The space in next line seems like auto-indentation at work (and thus correct), but the space in previous line should remain there.
  2. In an empty line writing only space and placing the cursor back to the start of the line and than pressing new-line, there will be 2 spaces in next line. By placing the cursor again at start of line and pressing new-line it will double again the spaces in next line. Again, the doubling of spaces is auto-indentation working, but in this case I believe it to be wrong. Auto-indent should not trigger if cursor is placed at start of line.

This seems like an issue in auto-indentation implementation or it is getting confused in which order the space and new-line characters are. Maybe some array/vector that has reversed order?

It is difficult to explain the above with words (and I am not sure that I succeeded), so I made short video.

https://user-images.githubusercontent.com/33322918/123124189-c05cb600-d447-11eb-91fd-934de3e07e82.mp4

NonStandardModel avatar Jun 23 '21 15:06 NonStandardModel

  • I cannot reproduce (2) currently, maybe it's fixed already?

  • (1) seems to be intentional, see https://github.com/SerenityOS/serenity/blob/c2e2b9d2ae4f5f20600e20f627199fa57365b5ca/Userland/Libraries/LibGUI/TextEditor.cpp#L1548-L1564

this could be a use case for that?

Peek 2022-10-29 23-10.webm

so the empty line doesn't have only spaces but you can keep writing the indented block?

premek avatar Oct 29 '22 21:10 premek