AndroidIDE icon indicating copy to clipboard operation
AndroidIDE copied to clipboard

[Bug]: Pasted text references wrong block level to do its formatting.

Open gituser1000000 opened this issue 2 years ago • 1 comments

What happened?

Example:

copied text: if (true) { myInt = 0; } else { myInt = 1; }

Before pasting: public class RootClass { 1111public RootClass() { 11112222{ 111122223333{ 1111222233334444{ 11112222333344445555{ 111122223333444455556666paste-here 11112222333344445555} 1111222233334444} 111122223333} 11112222} 1111} }

After pasting: public class RootClass { 1111public RootClass() { 11112222{ 111122223333{ 1111222233334444{ 11112222333344445555{ 111122223333444455556666if (true) { 111122223333myInt = 0; 11112222} else { 111122223333myInt = 1; 11112222} 11112222333344445555} 1111222233334444} 111122223333} 11112222} 1111} }

No matter how deep the level (6, 7, 8, ...), it always puts the text at the 2nd level, except for the first line because that's where we put the cursor before pasting.

What's the expected behavior?

Pasted text should be properly formatted at the correct position.

What version of AndroidIDE you're using?

v2.5.2 (debug builds)

Relevant log output

No response

Duplicate issues

  • [X] This issue has not been reported yet.

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

gituser1000000 avatar Aug 22 '23 15:08 gituser1000000

This is probably an issue with tree-sitter based indentation. I think we should use something else (probably the previous implementation or something new that we could implement in the Java LSP).

itsaky avatar Aug 26 '23 04:08 itsaky