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

Search panes #1521

Merged
merged 77 commits into from
Jul 18, 2022
Merged

Search panes #1521

merged 77 commits into from
Jul 18, 2022

Conversation

msirringhaus
Copy link
Contributor

@msirringhaus msirringhaus commented Jun 17, 2022

Current draft, before I start working on it in earnest in 2 weeks.

  • New Search-mode
  • Live highlighting of the needle in the viewport
  • Continue searching when scrolling
  • Use styles for colors
  • Search not only the viewport but all of the scrollbuffer
  • Actually move the viewport upon searching forward/backward
  • Search options
    • Case insensitive
    • Wrapping
    • Whole words only

@msirringhaus msirringhaus marked this pull request as ready for review July 1, 2022 11:46
@msirringhaus msirringhaus changed the title WIP: Search panes Search panes Jul 1, 2022
@imsnif imsnif self-assigned this Jul 4, 2022
@imsnif
Copy link
Member

imsnif commented Jul 4, 2022

Hey @msirringhaus - I took an initial look and this looks great! I'm going to test it and review it over the next few days and give feedback.

Copy link
Member

@imsnif imsnif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've had a chance to do a full review. First thing, let me say: this is top-notch work. You dived head-first into a non-trivial code-base, figured it out and managed to add a very non-trivial feature. Your changes are concise, not touching more than they absolutely have to, and I was personally very impressed by your eye for edge cases an UX details.

I left comments in the code, mostly about moving stuff around and breaking large functions down to make them more maintainable (I realize I'm holding you to higher standards than some of the code-base, but I have to be sure I'm able to effortlessly maintain this on my own if I have to).

Additionally, some UX comments and minor bugs:

  1. In the case of terminals as opposed to the web for example, I think the next/previous commands should be inverse. 99% of the time the user will search for something while being on the last line of the viewport and is looking up. The next instance should be the one above them.
  2. A small bug: search results that are at the end of the line color the background of the whole line until the end
  3. The various search toggles need some sort of UI indication. It's impossible for me as a user to know whether my current search is case-sensitive or whole-word. See next point for a suggestion.
  4. I think the search term should appear in the pane frame while searching as well. Something like SEARCHING FOR: my-search-term, in the future we could add the occurrence too, eg. SEARCHING FOR: my-search-term 5/10. This can also be a good place to indicate the search feature toggles, eg. SEARCHING FOR: my-search-term [case-sensitive, whole-word] - I'm not tied to the square bracket, just a suggestion.
  5. One big snag here is that search is unusable without pane frames (eg. when we toggle them off with ctrl-p + z). The best solution here would be to somehow move the search UI somewhere else (such as the status-bar), but I realize that can be a tall order. We could probably get away with temporarily enabling pane-frames while searching and disabling them again when exiting search. Not ideal... unless you have a better idea?

As we discussed last week on our Matrix chat, I'll take it upon myself to implement changing the foreground color of searches to make them more readable. But I think I'll wait until you implement these changes to avoid merge conflicts.

Once again - awesome work. Looking forward to seeing this merged and released.

(EDIT) Almost forgot:
We also need to fix the e2e tests. I think they're failing because the UI here was changed. They also use cargo insta - you can find more info about running them here: https://github.com/zellij-org/zellij/blob/main/CONTRIBUTING.md#running-the-end-to-end-tests
And also: the CI is complaining about rustfmt and clippy. We'll also need to fix these before merging.

zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/grid.rs Show resolved Hide resolved
zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/plugin_pane.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/terminal_pane.rs Outdated Show resolved Hide resolved
zellij-server/src/screen.rs Outdated Show resolved Hide resolved
zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
@imsnif
Copy link
Member

imsnif commented Jul 13, 2022

Hey @msirringhaus - I merged main as promised. I still owe you fixing the foreground styles of the marked results, but I think it's not blocking for you, right? I'll try to get to it ASAP

@msirringhaus
Copy link
Contributor Author

Hey @msirringhaus - I merged main as promised. I still owe you fixing the foreground styles of the marked results, but I think it's not blocking for you, right? I'll try to get to it ASAP

Wow, thanks! And no, it's not blocking. I'll try to get to the rest of the feedback ASAP as well, so we can hopefully land this thing

@imsnif
Copy link
Member

imsnif commented Jul 14, 2022

Right, @msirringhaus - I just implemented the search foreground. Let me know what you think. Also, I took the liberty of updating the e2e snapshots to get that off your plate. Let me know if I can help with anything else!

@msirringhaus
Copy link
Contributor Author

msirringhaus commented Jul 14, 2022

Awesome about the merge and implementation of the frontcolor! It looks perfect now! I love it.
I tried to address all inline comments and AFAIK, there is only one thing left:

A small bug: search results that are at the end of the line color the background of the whole line until the end

I'll try to take a look at this ASAP, but not today anymore :-)

Edit: About renaming forward/backward to up/down: I was very happy I did that, before I started refactoring the search-functions. It is so much more clear which direction I'm currently looking at :-)

@msirringhaus
Copy link
Contributor Author

Ok, I found the highlighting-bug. Unless I overlooked something, we are all set now?

imsnif and others added 9 commits July 18, 2022 09:16
…lij-org#1586)

* fix(terminal): persist cursor hide/show through alternate screen

* style(fmt): rustfmt

* style(clippy): make clippy happy
…ellij-org#1587)

* fix(editor): handle editor/visual/configured editor with arguments

* style(fmt): rustfmt
…1584)

* if left click is on pane border do not forward to application

* properly handle frames

* fix comment

* fix another comment

* add tests, fix edge case
Flake lock file updates:

• Updated input 'crate2nix':
    'github:kolloch/crate2nix/2d20dec4ae330f39b0bebeb8eb4a201b58d2b82c' (2022-07-09)
  → 'github:kolloch/crate2nix/45d97c7ce62c3d53954743057ceb32e483c31acd' (2022-07-12)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/b39924fc7764c08ae3b51beef9a3518c414cdb7d' (2022-07-08)
  → 'github:nixos/nixpkgs/4a01ca36d6bfc133bc617e661916a81327c9bbc8' (2022-07-14)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/3dfc78e42a285caaf83633224a42e7fb7dde191b' (2022-07-10)
  → 'github:oxalica/rust-overlay/2cd36d4aef875867ee1d7963541ccb3ae50b358c' (2022-07-16)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@imsnif
Copy link
Member

imsnif commented Jul 18, 2022

@msirringhaus - I found and fixed a minor bug: if you searched for something, then moved to a different pane without switching modes (eg. with Alt + LeftArrow), then switched back to normal mode (pressing Enter) and then came back to the original pane, the searches would still be highlighted (which is okay) and not get cleared when you scroll (which is not so nice). Fixed this by clearing the search results (providing they exist) every time the user enters characters to the terminal.

Otherwise, this looks great. I'll wait for CI to pass and then do one last go before I merge.

@imsnif
Copy link
Member

imsnif commented Jul 18, 2022

...and another minor one fixed: when the pane being search was being actively updated, the search results would get out of whack as well (eg. tail -f /my/active/log/file and then search for something).

We already had a mechanism for handling this when scrolling, so I tapped into it.

Copy link
Member

@imsnif imsnif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msirringhaus - everything looks good to me and I'm about to merge this.

Thank you very much for your sustained and tremendous efforts here. This has been a greatly requested and anticipated feature for a long time and your implementation is fantastic. I'm very much looking forward to releasing it in the near future.

I also had fun working with you on this, and while I know you having time to contribute was a special circumstance, I still hope to see contributions from you to Zellij in the future.

@imsnif imsnif merged commit bae1548 into zellij-org:main Jul 18, 2022
@msirringhaus
Copy link
Contributor Author

Well no. Thank you very much for your tremendous patience, guidance and for the fun experience! :-)
Hopefully, it was not the last Hackweek (usually once per year).
In the meantime, I'm trying to get official builds of zellij into openSUSE, by trying to get WASM-support for Rust active.

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.

7 participants