Skip to content

Commit 21ffaa3

Browse files
committed
Improve CWD initialization by replacing ppid check with TERM-based detection
1 parent 0dc48d3 commit 21ffaa3

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

editor/editor.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ type Editor struct {
119119
side *WorkspaceSide
120120
savedGeometry *core.QByteArray
121121
prefixToMapMetaKey string
122-
macAppArg string
123122
configDir string
124123
homeDir string
125124
version string
@@ -132,7 +131,6 @@ type Editor struct {
132131
notifications []*Notification
133132
workspaces []*Workspace
134133
args []string
135-
ppid int
136134
keyControl core.Qt__Key
137135
keyCmd core.Qt__Key
138136
windowSize [2]int
@@ -243,13 +241,12 @@ func InitEditor(options Options, args []string) {
243241
e.putLog("Detecting the goneovim configuration directory:", e.configDir)
244242
e.overwriteConfigByCLIOption()
245243

246-
// get parent process id
247-
e.ppid = os.Getppid()
248-
e.putLog("finished getting ppid")
249-
250244
// put shell environment
251245
e.setEnvironmentVariables()
252246

247+
// set application working directory path
248+
e.setAppDirPath(e.homeDir)
249+
253250
// create qapplication
254251
e.putLog("start generating the application")
255252
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
@@ -504,15 +501,8 @@ func (e *Editor) setAppDirPath(home string) {
504501
if runtime.GOOS == "windows" {
505502
return
506503
}
507-
if runtime.GOOS == "darwin" {
508-
if !(e.ppid == 1 && e.macAppArg == "") {
509-
return
510-
}
511-
}
512-
if runtime.GOOS == "linux" {
513-
if e.ppid != 1 {
514-
return
515-
}
504+
if os.Getenv("TERM") != "" {
505+
return
516506
}
517507

518508
path := core.QCoreApplication_ApplicationDirPath()
@@ -655,7 +645,7 @@ func (e *Editor) connectAppSignals() {
655645
switch event.Type() {
656646
case core.QEvent__FileOpen:
657647
// If goneovim not launched on finder (it is started in terminal)
658-
if e.ppid != 1 {
648+
if os.Getenv("TERM") != "" {
659649
return false
660650
}
661651
fileOpenEvent := gui.NewQFileOpenEventFromPointer(event.Pointer())

0 commit comments

Comments
 (0)