Skip to content

terminal: Fix drag-and-drop in vertical terminal panels#49825

Merged
SomeoneToIgnore merged 15 commits intozed-industries:mainfrom
transitoryangel:fix/vertical-terminal-file
Mar 6, 2026
Merged

terminal: Fix drag-and-drop in vertical terminal panels#49825
SomeoneToIgnore merged 15 commits intozed-industries:mainfrom
transitoryangel:fix/vertical-terminal-file

Conversation

@transitoryangel
Copy link
Copy Markdown
Contributor

Closes #49800

Adds handle_drop to Item & ItemHandle, which allows an active item in a pane to consume drop events before the pane does.

Release Notes:

  • terminal: Fix drag-and-drop not working in vertical terminal panels

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 22, 2026
@SomeoneToIgnore SomeoneToIgnore self-assigned this Feb 24, 2026
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Seems that we do not swap items when drag and drop on their tab:

swap.mov

IIRC that tab swapping code is in the pane.rs and the terminal tab as to skip the drop processing.

It would be good to get all such things tested beforehand, as definitely saves time on iterating.


Overall works, nice, we need a few more tweaks to make it good and merge.

@transitoryangel
Copy link
Copy Markdown
Contributor Author

transitoryangel commented Feb 27, 2026

Went through feedback and did the following -

  • removed custom_drop_handle entirely as it seemed redundant with the new handle_drop addition, moved the remaining terminal panel use to the items themselves, and moved the debugger UI's use of it to the SubView items
  • added a parameter is_pane_target to handle_drop to discern whether an item was dropped on the item's containing pane itself or the item's tab

Also went and made the documentation for handle_drop a little more clear.

zed.mov

@transitoryangel transitoryangel force-pushed the fix/vertical-terminal-file branch from 26b30fe to 4463b82 Compare February 27, 2026 03:36
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Great, I see things start to work for the terminal and its tabs!

I have not checked the debugger code changes well enough yet, but let's deal with the general architecture first and then I can come back there — have posted a question below.


One remaining "bug" to consider is the fact that we can drag a tab/file around the terminal tab and it will show different dimming, as if that thing could split the terminal — yet all that happens is that the terminal gets that tab/file's path pasted.

What feels more appropriate is either do a split, or avoid drawing that "split possibility" entirely, now it's quite odd:

odd.mov

Before, we did not have such a mixture of types in the same pane, but now all the edge cases jump at us at once and we'd better cover them all.

@transitoryangel
Copy link
Copy Markdown
Contributor Author

One remaining "bug" to consider is the fact that we can drag a tab/file around the terminal tab and it will show different dimming, as if that thing could split the terminal — yet all that happens is that the terminal gets that tab/file's path pasted.

Regarding this - I think keeping the regular terminal pane's splitting behaviour (only split for other terminal items under certain circumstances) is favourable - but this runs into the same issue originally causing the dropping inconsistencies where panes created by splits don't have the same characteristics (in this case, the can_split_predicate).

And again, it seems like the can_split_predicate is only used by the debugger UI and the terminal view. So, my instinct is to go ahead and make another per-Item method to handle splits. Does this sound fine?

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

make another per-Item method to handle splits

I guess I might miss something, but from the bird's view, this adjustment seems odd: it's the pane/pane overlay that knows whether we drop on the whole item or on its part?
If the former, then we're supposed to call item's drop handler; if the latter — we're not supposed to call anything like that at all but rather create another element?
If this is true, no extra methods is needed at all, just the pane has to get more logic added?

If I'm mistaken somehow, I wonder whether we can consider adding a parameter like "dropping into full item/dropping into part of the item" that will be handled differently by each drop handler.
Yet, I am not fond of the direction this "new parameter"/"new method" approach moves to, so if this indeed the case, it would be great to just understand what's causing issues here — and maybe it's fine to leave things as is now, as this all is definitely a very nice improvement already.
Later, we can work on a follow-up PR to fix this bug separately, to avoid bloating the current PR more.

@transitoryangel transitoryangel force-pushed the fix/vertical-terminal-file branch from 14b3e19 to 488f27d Compare March 4, 2026 01:50
@transitoryangel
Copy link
Copy Markdown
Contributor Author

not sure what the deal is with the git history there, oops.. I wrote a test for is_pane_target and plan on writing a different one in the morning to validate terminal dropping behaviour specifically, and I agree that the current PR is already kind of extensive enough and a follow up PR is warranted.

couldn't get clippy to run last night.. this is what i get
Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thanks a lot for all this work!

@SomeoneToIgnore SomeoneToIgnore merged commit 49ef205 into zed-industries:main Mar 6, 2026
28 checks passed
@transitoryangel
Copy link
Copy Markdown
Contributor Author

Thanks for all of your advice!

@transitoryangel transitoryangel deleted the fix/vertical-terminal-file branch March 6, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

Status: Shipped by the Guild

Development

Successfully merging this pull request may close these issues.

Drag & drop file in terminal to print path partially works

3 participants