Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Redone #4189, working preview scrolling #11441

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

GNUSheep
Copy link
Contributor

@GNUSheep GNUSheep commented Aug 7, 2024

Finally redone preview scrolling on current master. Works pretty fine.

I used code from: @Manosmer, and make it work with current version of helix.

Connects #1614

@GNUSheep GNUSheep changed the title Redone helix-editor#4189, working preview scrolling Redone #4189, working preview scrolling Aug 7, 2024
@thomasaarholt
Copy link
Contributor

Current keybindings:

  • alt-j / shift-down - Move preview down scroll-lines at a time
  • alt-k / shift-up - Move preview up scroll-lines at a time
  • alt-d - Move preview down half height of the preview area
  • alt-u - Move preview up half height of the preview area
  • alt-f / alt-PageDown - Move preview down one full preview area height
  • alt-b / alt-PageUp - Move preview up one full preview area height

Originally posted by @EpocSquadron in #4189 (comment)

@thomasaarholt
Copy link
Contributor

I do observe that when scrolling, the syntax highlighting does not update. Only the text first shown in the preview pane is syntax highlighted.

Screenshot 2024-08-18 at 19 15 50

@GNUSheep GNUSheep force-pushed the scroll_preview_fixed branch from 05e8d71 to ecd415f Compare August 19, 2024 12:39
@GNUSheep GNUSheep force-pushed the scroll_preview_fixed branch from ecd415f to a69ea1d Compare August 19, 2024 13:00
@GNUSheep
Copy link
Contributor Author

@thomasaarholt

Hi! Thank you for your help. I fixed my mistakes, and now all should work well.

My only concern is about keybinding alt-PageUp, because as mentioned before:

I'm not 100% certain alt- is valid with PageUp/PageDown in terminals, but worth a try.

I tried the above on iTerm2 without success. Therefore, I did not include those keybindings. It might be a limitation just on my platform though.

In my case alt-PageDown works pretty fine, but alt-PageUp doesn't.
I tested on alattracity, and gnome terminal and got same result.

But as mentioned above it might be just a limitation on my platform.

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Aug 28, 2024
@GNUSheep
Copy link
Contributor Author

@archseer
@the-mikedavis

@EmrysMyrddin
Copy link

I've tried it, works very well, very welcomed addition ! I hope it will be merged soon :-)

@EmrysMyrddin
Copy link

I'm using Helix based on your PR, and I came across another issue:
image

Here the diagnostic is miss-rendered. It should not underline the whole comment.

Here how it looks in the main buffer:
image

Note: the diagnostic is rendered in the preview only if the file have been opened at least once since Helix started.

@David-Else
Copy link
Contributor

@thomasaarholt

My only concern is about keybinding alt-PageUp, because as mentioned before:

I'm not 100% certain alt- is valid with PageUp/PageDown in terminals, but worth a try.

I tried the above on iTerm2 without success. Therefore, I did not include those keybindings. It might be a limitation just on my platform though.

In my case alt-PageDown works pretty fine, but alt-PageUp doesn't. I tested on alattracity, and gnome terminal and got same result.

But as mentioned above it might be just a limitation on my platform.

I am not a fan of using the Alt key, particularly with the Alt + PageUp/PageDown combinations. I have noticed that currently, PageUp/PageDown seems to jump up and down the file or item list by a seemingly random amount in different pickers. I really can't find a good use for the current functionality in the picker. It would be better to use PageUp/PageDown for preview scrolling instead, similar to how LazyGit does. Now that we have Pickers v2, it makes more sense to refine the search rather than scrolling through the list of items in such large increments.

@GNUSheep
Copy link
Contributor Author

GNUSheep commented Sep 20, 2024

@EmrysMyrddin

Hi! Thank u for using helix based on my PR.
I fixed that bug,
(I just forgot to change offset.anchor in doc_diagnostics_highlights)

image
image

If u find more bugs I will be happy to fix them :)

@GNUSheep
Copy link
Contributor Author

@David-Else
Hello! Looking at the code PageUp and PageDown, moves up or down by a exactly one page. But I agree with you that it is not so useful, I think that many people just search by using search bar rather than scrolling up.

Using just PageUp or PageDown seems like nice idea.

@GNUSheep
Copy link
Contributor Author

@qiu-x
Copy link

qiu-x commented Dec 30, 2024

Are there any blockers before this can be merged?
@the-mikedavis

@rockboynton
Copy link
Contributor

rockboynton commented Jan 12, 2025

I can consistently reproduce a panic when using this. (disclaimer, I do have other branches too merged into my fork too, but I can only reproduce this issue when this PR is included):

  1. Open a repo with lsp (rust-analyzer in my case)
  2. Open global symbol picker (<space>S)
  3. Typy-type
  4. The panic occurs sometimes while typing, sometimes when I hit <esc> to close, sometimes if I close, re-open the global symbol picker and type more.

Can you try to reproduce? It may be possible it is just my unique setup, but like I said, I've only seen this when using this PR.

󱞪 RUST_BACKTRACE=full hx .
thread 'main' panicked at /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/ropey-1.6.1/src/slice.rs:453:41:
called `Result::unwrap()` on an `Err` value: Line index out of bounds: line index 6457, Rope/RopeSlice line count 436
stack backtrace:
   0:     0x55555661be0b - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b9dad2a88e955ff
   1:     0x55555577884b - core::fmt::write::h4b5a1270214bc4a7
   2:     0x555556617b73 - std::io::Write::write_fmt::hd04af345a50c312d
   3:     0x55555661de2a - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed
   4:     0x55555661da77 - std::panicking::default_hook::h3cacb9c27561ad33
   5:     0x55555661e6a8 - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b
   6:     0x55555661e397 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44
   7:     0x55555661c2d9 - std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e
   8:     0x55555661e024 - rust_begin_unwind
   9:     0x555555680593 - core::panicking::panic_fmt::h3d8fc78294164da7
  10:     0x555555680a26 - core::result::unwrap_failed::hfa79a499befff387
  11:     0x555556106c47 - <helix_term::ui::picker::Picker<I,D> as helix_term::compositor::Component>::render::h33dd85836441c517
  12:     0x555556377c03 - helix_term::application::Application::render::{{closure}}::h108963a17ac2b9f0
  13:     0x55555638c7b0 - hx::main_impl::{{closure}}::h1105d798dbc7e566
  14:     0x5555563898c8 - tokio::runtime::park::CachedParkThread::block_on::h390deff2c402d9ac
  15:     0x55555642a4de - tokio::runtime::context::runtime::enter_runtime::h6b594ce14328c083
  16:     0x555556439f46 - tokio::runtime::runtime::Runtime::block_on::h03ec0308555e9d53
  17:     0x5555563cdb73 - hx::main::h3debb9f5c1109bd7
  18:     0x5555563f4143 - std::sys::backtrace::__rust_begin_short_backtrace::ha704d94dc880694d
  19:     0x5555563fbb3d - std::rt::lang_start::{{closure}}::hf9a24b6ef71d3115
  20:     0x55555660e685 - std::rt::lang_start_internal::h5e7c81cecd7f0954
  21:     0x5555563cdc65 - main
  22:     0x7ffff7c2a1fc - __libc_start_call_main
  23:     0x7ffff7c2a2b9 - __libc_start_main_alias_2
  24:     0x5555556f3535 - _start
  25:                0x0 - <unknown>

@GNUSheep GNUSheep force-pushed the scroll_preview_fixed branch from c61eea4 to 40d9547 Compare January 15, 2025 12:36
@GNUSheep
Copy link
Contributor Author

GNUSheep commented Jan 15, 2025

@rockboynton

Hi! Thank you for pointing out the error. This panic was indeed related to this PR. I missed it during testing - perhaps I didn't run enough tests - so I am sorry for that oversight.

Together with @qiu-x, we have fixed the issue. We switched to using offset_anchor instead of offset_vertical_offset to move the preview, and this resolved the problem. We ran several tests and did not encounter any more panics.

I hope everything works fine now. I look forward to your feedback! Please let me know if everything is working as expected
I really hope it does. :)

Thank you once again!

@nik-rev
Copy link
Contributor

nik-rev commented Jan 28, 2025

this PR also closes #1614

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-helix-term Area: Helix term improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants