Repository navigation
[FEATURE REQUEST] Drag a file or folder from Files onto the terminal to type its path - #56
Merged
Raiden-MeixElysia merged 1 commit intoNov 2, 2026
Conversation
A file or folder dragged from the Files panel and dropped on the terminal types its absolute path at the cursor, kept literal for the session's shell and followed by a space, as a dropped OS file does. Ely's Tree rows already drag a TreeDrag value, now public in ELY-Open-Source/Ely-GPUI-Components#9; the terminal takes a second on_drop for it, gpui matching each drop by its type, and the workspace resolves the node's key through Files and types the path with the drop's quoting. The Ely dep is pinned by rev to the PR's branch until it merges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type
What and why
The Files panel's tree is click-to-open only: there is no quick way to get a file's path into the shell. This lets a row be dragged onto the terminal, where it is dropped; the node's absolute path is then typed at the cursor, kept literal for the session's shell and followed by a space, exactly as an OS file dropped on the terminal already is. Folders drag the same way.
How it works:
Treerows already drag aTreeDragvalue with the node's label as a ghost, but the type waspub(crate), and gpui dispatches an in-app drop only to listeners whose type matches the drag value's exactly. Lists: TreeDrag is public, so a drop past the tree's rows names the dragged node Ely-GPUI-Components#9 makesTreeDragpublic withkey()/label(); until it merges, the Ely dep is pinned by rev to that PR's branch (a one-lineCargo.toml/Cargo.lockchange repoints it at the org's merge commit).on_dropforTreeDragnext to the existingExternalPathsone; gpui matches each drop by its type, so the two coexist.TerminalEvent::Dragged; the workspace resolves it throughFiles::path— a key only resolves for a node Files actually listed, so a drag from any other tree types nothing, logged — andTerminalView::type_pathstypes it with the drop's quoting, as a paste, so bracketed paste, selection clearing and IME behaviour are the drop's own.TreeDrag's still-privateowner.PRD, TASKS (T139), the acceptance table and AGENTS.md's record hold the change.
How it was tested
scripts/check.shon Windows 11:cargo fmt --checkandcargo clippy --all-targets -- -D warningspass; 404 of 405 tests pass, the one failure (term::shell::windows_tests::only_a_bare_cmd_typed_takes_the_marked_prompt) failing identically on a clean checkout ofmainon this machine, so it is environmental and pre-existing.check.sh(comment and 500-line rules) passes for the touched files;tasks/reviews.mdstands 5 lines over onmainalready.term::droppath; the key→path resolver it now relies on is covered byfiles' tree-key tests.app: … dragged onto the terminal/terminal …: 1 paths droppedlog lines.Checklist
[FEATURE REQUEST],[BUG REPORT]or[Other]main)中文概述(供审核者参考)
功能:从右侧 Files 文件树中拖动文件或文件夹到终端区域,松开鼠标后,该路径会按当前会话 shell 的引号规则自动输入到命令行(与系统文件拖入终端的行为一致)。
实现要点:Ely 的
Tree行本身已支持拖拽,但其拖拽值TreeDrag是 crate 私有类型,而 gpui 按类型精确分发 drop 事件,因此需要先合并配套 PR ELY-Open-Source/Ely-GPUI-Components#9(将其公开并导出)。本 PR 中终端注册了第二个on_drop接收该拖拽值,经 workspace 用Files::path解析出真实路径后,复用现有拖放的引号与粘贴逻辑输入路径。Ely 依赖暂时指向 fork 上的提交,待 Ely PR 合并后改回组织仓库的 rev。尚未在真机上手动验证拖拽操作,已在 acceptance 表中注明。