haystackeditor / haystack-editor

Other
843 stars 34 forks source link

Code folding breaks when viewing "one level down" in a file #17

Closed nyanpasu64 closed 2 weeks ago

nyanpasu64 commented 1 month ago

Does this issue occur when all extensions are disabled?: (cannot test, "one level down" depends on semantic information from extensions like clangd)

Haystack Version: 0.19 VS Code Version: 1.90.0 Chromium: 122.0.6261.156 OS: {3 } (Arch Linux)

Steps to Reproduce:

  1. Open a file, go "one level down" into a C++ namespace/etc., or press F12 on a symbol to open a sub-file editor.
  2. Try to fold a code block using Ctrl+Shift+[ or clicking the v arrow on the left of a block.

The wrong region of code is folded, or none at all.

Screenshot_20241003_071140

Here, when I try folding a comment on line 62 (first line shown 24), VS Code highlights the block starting at line (62-24+1 = 39), which ends at line 51. Then it folds all lines in the editor from 62 until (51+24-1 = 74) inclusive.

It appears the bug is that you're sending window-relative line numbers to the code which identifies a foldable block (which expects document-relative line numbers), then interpreting the document-relative block boundary returned as a window-relative range of lines to hide.

This may be the same bug as #14.

Similarly, renaming symbols (with F2) fails when in a subscope of a file, but only if one or more lines were truncated from the beginning of the file:

Screenshot_20241003_071603

AkshaySG14 commented 1 month ago

This should be fixed in 0.19.1 on the website. Please let me know if something is still broken here!

nyanpasu64 commented 1 month ago

For some reason I installed the Arch AUR 0.19.1 based on the 0.19.1 Linux package, but it still self-reports as 0.19 in About and the bug isn't fixed?

nyanpasu64 commented 2 weeks ago

Folding still fails on 0.19.2 on Linux, but with rust-analyzer this time. I can always fold and unfold the arrows, but the corresponding lines in the file don't get hidden.

AkshaySG14 commented 2 weeks ago

Will take another look!

AkshaySG14 commented 2 weeks ago

This should be fixed in 0.19.3! Please let me know if that's not the case!

nyanpasu64 commented 2 weeks ago

Seems to work now.