zed icon indicating copy to clipboard operation
zed copied to clipboard

Alternate files with ctrl-6

Open robfalken opened this issue 1 year ago • 7 comments

This is my stab at #7709

I realize the code is flawed. There's no test coverage, I'm using clone() and there are probably better ways to hook into the events. Also, I didn't know what context to use for the keybinding. But maybe with some pointers from someone who actually know what they're doing, I can get this shippable.

Release Notes:

https://github.com/zed-industries/zed/assets/261929/fc7997b5-9354-45c0-9b83-31925b19616b

robfalken avatar May 03 '24 18:05 robfalken

We require contributors to sign our Contributor License Agreement, and we don't have @robfalken on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar May 03 '24 18:05 cla-bot[bot]

We require contributors to sign our Contributor License Agreement, and we don't have @robfalken on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar May 03 '24 18:05 cla-bot[bot]

@cla-bot check

robfalken avatar May 03 '24 18:05 robfalken

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar May 03 '24 18:05 cla-bot[bot]

Thanks for this! Looks like the linter is complaining about some unused variables (you can fix that by naming them _ or similar).

If we want to support this more like vim, we should store the alternate file per-pane instead of per workspace. I think you can re-use much of the approach from here, but move it into the Pane instead (use pane::AlternateFile, and register the action there).

If you'd like help getting this over the line, feel free to book time here: https://calendly.com/conradirwin/pairing.

ConradIrwin avatar May 06 '24 18:05 ConradIrwin

@ConradIrwin thanks for the feedback!

I booked the earliest available slot, but in the meantime I'm trying to get as close to the finish line as possible.

I have moved from the workspace context into panes. I had to change method of alternating files from workspace.open_path to pane.add_item, so now it's behaving a little bit strange.

https://github.com/zed-industries/zed/assets/261929/ed3ac969-7beb-4dfd-a094-bec90c377b60

I am guessing I should use activate_item or something, rather than add_item. But I couldn't figure out how to get that to work. Do you have any thoughts on what kind of references to store, and what method to use to switch to the alternative file?

robfalken avatar May 07 '24 16:05 robfalken

It looks like we just need to check fi the item is already active in this pane, and if so reactivate it. Pushed up a potential fix.

ConradIrwin avatar May 10 '24 03:05 ConradIrwin

Oh, perfect. That's is exactly what I wanted to do, but couldn't figure out how. Thanks!

I updated my screencast in the PR description, and rebased my branch. I can't run the tests, though. I just get this error:

error: failed to run custom build command for `live_kit_server v0.1.0 (/Users/rf/Projects/zed/crates/live_kit_server)`

Caused by:
  process didn't exit successfully: `~/Projects/zed/target/debug/build/live_kit_server-2648d7b32afc52c2/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at crates/live_kit_server/build.rs:5:10:
  called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: Could not make proto path relative: protocol/livekit_room.proto: No such file or directory\n" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@ConradIrwin I have booked a pairing session at Friday May 10, 2024 ⋅ 11am – 12pm (Mountain Time - Denver) to work on this PR. Is there anything else you'd like to improve, or do you think it's good enough that we should cancel that session?

robfalken avatar May 10 '24 08:05 robfalken