GUI 程序(-H windowsgui)起 console 子进程时若未设 HideWindow, Windows 会为其分配新控制台。refreshGit 一次连跑 3 个 git 进程 = 3 个闪窗(主因),另有 taskkill 和 go vet 两处。 统一 procAttr() 模式(Windows 返回 HideWindow:true,其他平台 nil): - internal/git: 新建 procattr_windows/other.go,run/runOut 挂上 - internal/task: killTree(taskkill)挂上 - internal/app: 新建 procattr_windows/other.go,go vet 挂上
16 lines
504 B
Go
16 lines
504 B
Go
//go:build windows
|
|
|
|
package git
|
|
|
|
import "syscall"
|
|
|
|
// procAttr 让子进程不弹控制台窗口。
|
|
//
|
|
// 程序本身是 -H windowsgui(没有控制台),它起的 console 子进程
|
|
// (git)默认会新建一个控制台——表现为命令窗口一闪而过。
|
|
// 进项目时 refreshGit 连跑 rev-parse + status + numstat,一次闪三个。
|
|
// lsp/dap 包已有同样的处理,这里保持一致。
|
|
func procAttr() *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{HideWindow: true}
|
|
}
|