Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Overhauling Zellij's Resize & Layout System #568

Merged
merged 85 commits into from
Aug 28, 2021
Merged

Conversation

TheLostLambda
Copy link
Member

@TheLostLambda TheLostLambda commented Jun 3, 2021

Should close #619 and #406 when merged :)

This change introduces the `Fixed` and `Percent` dimensions for pane
sizes, laying the groundwork for a parametric resize / layout system
down the line.

IMPORTANT: This commit is hillariously broken and doesn't compile.
@imsnif
Copy link
Member

imsnif commented Aug 26, 2021

Hey @TheLostLambda
Great work so far. This is definitely a tremendous effort! I think it would be great both for the functionality and for the code base once this is merged.

I took this for a spin and found some issues:

  1. When resizing the terminal window to a very small width, there's a hard crash:
        Error occured in server:
        Originating Thread(s):
        1. screen_thread: TerminalResize
        2. plugin_thread: Render

        Error: thread 'wasm' panicked at 'called `Result::unwrap()` on an `Err` value: RuntimeError { source: Trap(UnreachableCodeReached), wasm_trace: [FrameInfo { module_name: "<module>", func_index: 1663, function_name: Some("__rust_start_panic"), func_start: SourceLoc(501416), instr: SourceLoc(501417) }, FrameInfo { module_name: "<module>", func_index: 1656, function_name: Some("rust_panic"), func_start: SourceLoc(500444), instr: SourceLoc(500483) }, FrameInfo { module_name: "<module>", func_index: 1649, function_name: Some("_ZN3std9panicking20rust_panic_with_hook17h308937c11f14a0b0E"), func_start: SourceLoc(498376), instr: SourceLoc(499568) }, FrameInfo { module_name: "<module>", func_index: 1637, function_name: Some("_ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17h2f1ffd2e7af6e54eE"), func_start: SourceLoc(496583), instr: SourceLoc(496718) }, FrameInfo { module_name: "<module>", func_index: 1636, function_name: Some("_ZN3std10sys_common9backtrace26__rust_end_short_backtrace17h0391a3209a34137cE"), func_start: SourceLoc(496525), instr: SourceLoc(496573) }, FrameInfo { module_name: "<module>", func_index: 1648, function_name: Some("rust_begin_unwind"), func_start: SourceLoc(498285), instr: SourceLoc(498366) }, FrameInfo { module_name: "<module>", func_index: 1736, function_name: Some("_ZN4core9panicking9panic_fmt17hf6b8f38d129daac6E"), func_start: SourceLoc(537720), instr: SourceLoc(537778) }, FrameInfo { module_name: "<module>", func_index: 1719, function_name: Some("_ZN4core9panicking5panic17haa6b780f40788db6E"), func_start: SourceLoc(520019), instr: SourceLoc(520095) }, FrameInfo { module_name: "<module>", func_index: 571, function_name: Some("_ZN7tab_bar4line15tab_line_prefix17h9264f28801c06ad0E"), func_start: SourceLoc(243619), instr: SourceLoc(246448) }, FrameInfo { module_name: "<module>", func_index: 573, function_name: Some("_ZN7tab_bar4line8tab_line17h4e89bbaeb373a6d2E"), func_start: SourceLoc(247211), instr: SourceLoc(247963) }, FrameInfo { module_name: "<module>", func_index: 427, function_name: Some("_ZN60_$LT$tab_bar..State$u20$as$u20$zellij_tile..ZellijPlugin$GT$6render17h3cc8604a9333131dE"), func_start: SourceLoc(206451), instr: SourceLoc(207828) }, FrameInfo { module_name: "<module>", func_index: 73, function_name: Some("_ZN7tab_bar6render28_$u7b$$u7b$closure$u7d$$u7d$17h33c27749257b30aeE"), func_start: SourceLoc(12904), instr: SourceLoc(13048) }, FrameInfo { module_name: "<module>", func_index: 122, function_name: Some("_ZN3std6thread5local17LocalKey$LT$T$GT$8try_with17h97d8310b9e1654bbE"), func_start: SourceLoc(20530), instr: SourceLoc(20695) }, FrameInfo { module_name: "<module>", func_index: 121, function_name: Some("_ZN3std6thread5local17LocalKey$LT$T$GT$4with17hba3182caed98ee8dE"), func_start: SourceLoc(20388), instr: SourceLoc(20445) }, FrameInfo { module_name: "<module>", func_index: 431, function_name: Some("render"), func_start: SourceLoc(211413), instr: SourceLoc(211522) }, FrameInfo { module_name: "<module>", func_index: 1824, function_name: Some("render.command_export"), func_start: SourceLoc(560686), instr: SourceLoc(560693) }], native_trace:    0: <unknown>
           1: <unknown>
           2: <unknown>
           3: <unknown>
           4: <unknown>
           5: <unknown>
           6: <unknown>
           7: <unknown>
           8: <unknown>
           9: <unknown>
          10: <unknown>
          11: <unknown>
          12: <unknown>
          13: <unknown>
          14: <unknown>
          15: <unknown>
          16: <unknown>
          17: <unknown>
          18: <unknown>
          19: <unknown>
          20: <unknown>
          21: <unknown>
          22: <unknown>
          23: <unknown>
          24: <unknown>
         }': zellij-server/src/wasm_vm.rs:145
           0: zellij_utils::errors::handle_panic
                     at zellij-utils/src/errors.rs:24:21
           1: zellij_server::start_server::{{closure}}
                     at zellij-server/src/lib.rs:137:13
           2: std::panicking::rust_panic_with_hook
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:626:17
           3: std::panicking::begin_panic_handler::{{closure}}
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:519:13
           4: std::sys_common::backtrace::__rust_end_short_backtrace
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:141:18
           5: rust_begin_unwind
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
           6: core::panicking::panic_fmt
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
           7: core::result::unwrap_failed
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/result.rs:1355:5
           8: core::result::Result<T,E>::unwrap
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/result.rs:1037:23
           9: zellij_server::wasm_vm::wasm_thread_main
                     at zellij-server/src/wasm_vm.rs:143:21
          10: zellij_server::init_session::{{closure}}
                     at zellij-server/src/lib.rs:388:21
          11: std::sys_common::backtrace::__rust_begin_short_backtrace
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys_common/backtrace.rs:125:18
          12: std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/mod.rs:481:17
          13: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:347:9
          14: std::panicking::try::do_call
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:401:40
          15: __rust_try
          16: std::panicking::try
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:365:19
          17: std::panic::catch_unwind
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panic.rs:434:14
          18: std::thread::Builder::spawn_unchecked::{{closure}}
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/thread/mod.rs:480:30
          19: core::ops::function::FnOnce::call_once{{vtable.shim}}
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5
          20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/boxed.rs:1575:9
              <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/boxed.rs:1575:9
              std::sys::unix::thread::Thread::new::thread_start
                     at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/sys/unix/thread.rs:71:17
          21: start_thread
          22: __GI___clone

  1. When resizing the terminal panes themselves, there are glitches and jumps. Here's a video example of a relatively simple case (it happens in other cases as well):
resize-bug.mp4
  1. When splitting down twice, the new pane overlaps. Again, this happened in other places too but this is the most basic example I could find:
split-down-bug.mp4
  1. Also, it seems to me like one can resize terminals below their minimum height... maybe this is related to some of the other issues?

@TheLostLambda
Copy link
Member Author

Hi @imsnif ! Some good finds!

Sorry for leaving that mess for you to look at, I introduced bugs 2 and 3 in the refactoring commit ee3eb2a after I'd done all of my testing! I'll have an updated (refactored and fixed) version today!

1 should just be an easy fix in the tab-bar code.

What do you mean in 4? Do they become smaller than the minimum when resizing the whole terminal or can you split things with a fixed-size window and get that effect?

Thanks again for giving this a look and sorry I busted things during my refactor!

@a-kenji
Copy link
Contributor

a-kenji commented Aug 26, 2021

@TheLostLambda,
This looks great, I have tried various resizes and everything
works flawlessly - even while toggling tiling/floating/fullscreen.

@TheLostLambda
Copy link
Member Author

@a-kenji
Thanks for giving things a test! I'm just re-adding a couple of unit tests that I lost early on in the refactor process, but I've done quite a bit of testing as well and am planning on merging things tonight!

I'm excited to have all of this work in main!

@TheLostLambda
Copy link
Member Author

Merge delayed until tomorrow because I just so happened to delete the biggest set of tests in the repo 😅

I'm fixing them up (mostly fixing the tests themselves) and should finish soonish :)

@TheLostLambda TheLostLambda merged commit 76a5bc8 into main Aug 28, 2021
@har7an har7an deleted the resize-overhaul branch October 23, 2022 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default to a proportionate split_size in layouts
3 participants