[Bug] 项目树删除时在窗口线程逐个同步执行废纸篓命令或 os.RemoveAll,大目录或多选删除会卡住界面

Open
#2,083 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, macos
Domain
desktop

Research direction

Start with desktop/internal/workbench/filetree_batch.go around removeTreeItems and treeRemovalDialog, then read filetree_menu.go around saveDocumentsThen and filetree_duplicate.go around moveToTrash. Trace how deletion runs for trash and permanent removal, then check the project’s existing tests for this flow. Done means large or multiple selections no longer block the window, the tree refreshes after completion, and failures are reported.

Written by the indexing model from the issue text.

Description

review: high
Platform / 平台

macOS

Area / 模块

Project and workspace / 项目与工作区

Lithe version / Lithe 版本

main 0a234bd8d

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

OS and architecture / 操作系统与架构

macOS,Apple Silicon(代码审查发现;Windows 走同一份 Go 代码,只是外部命令不同)

Environment / 环境信息

Viva 桌面端,项目树删除功能,与 JDK、Maven、语言服务器无关。

Steps to reproduce / 复现步骤
  1. 打开一个项目,在项目树里选中一个较大的目录,或者多选几十个文件。
  2. 右键选择“删除”,在确认弹窗里点“移到废纸篓”(或“永久删除”)。
  3. 删除进行时尝试滚动项目树、切换标签页或输入。
Expected behavior / 预期行为

删除在后台执行,窗口保持响应;完成后刷新项目树,失败时给出提示。

Actual behavior / 实际行为

这是代码审查发现的问题,还没有实测卡顿时长。从代码看,删除在窗口线程上同步执行:

  • desktop/internal/workbench/filetree_batch.go:221 的 treeRemovalDialog 通过 c.After 在窗口线程调用 removeTreeItems。
  • removeTreeItems(filetree_batch.go:142)在 saveDocumentsThen 的回调里逐个调用 treeMoveToTrash 或 os.RemoveAll。选中的文件没有在编辑器里打开时,saveDocumentsThen(filetree_menu.go:453)会同步调用这个回调,所以整个循环都跑在窗口线程上。
  • moveToTrash(filetree_duplicate.go:109)每一项都启动一个外部进程,并等它退出(CombinedOutput),用的是 context.Background(),没有超时:
    • macOS:osascript,让 Finder 删除;
    • Windows:powershell,加载 Microsoft.VisualBasic 后移到回收站;
    • 其他平台:gio trash。
  • 选中 N 项就串行启动 N 个进程,每个都要几百毫秒,窗口在这段时间里不会重绘。永久删除时 os.RemoveAll 删大目录(例如 node_modules、target)同样会阻塞窗口线程。
  • 未验证的推测:macOS 第一次让 Finder 删除时可能会弹出“自动化”授权框,用户回答之前窗口线程一直在等。
Logs or diagnostic output / 日志或诊断输出
未采集。问题来自对 main 0a234bd8d 的代码审查,没有运行时日志或耗时测量。
Screenshots or recordings / 截图或录屏

无。

Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复报告。
  • I removed secrets and personal data from the report. / 我已从报告中移除敏感信息和个人数据。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
3h 48m
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.