feat: added sorting of recently opened remeber paths
This commit is contained in:
26
app.go
26
app.go
@@ -187,11 +187,37 @@ func (a *App) Enter(value string) {
|
||||
}
|
||||
|
||||
func (a *App) EnterDir(value string) {
|
||||
updateRemeberPath(a, value)
|
||||
fmt.Printf("ghostty --working-directory=%s", value)
|
||||
runtime.Quit(a.ctx)
|
||||
}
|
||||
|
||||
func (a *App) OpenEditor(value string) {
|
||||
updateRemeberPath(a, value)
|
||||
fmt.Printf("czed %s", value)
|
||||
runtime.Quit(a.ctx)
|
||||
}
|
||||
|
||||
func updateRemeberPath(a *App, value string) {
|
||||
if a.remeberedPath[0] != value {
|
||||
remeberPath, err := GetRemeberPath()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
|
||||
nlist := []string{value}
|
||||
|
||||
for _, elm := range a.remeberedPath {
|
||||
if value != elm {
|
||||
nlist = append(nlist, elm)
|
||||
}
|
||||
}
|
||||
|
||||
err = os.WriteFile(remeberPath, []byte(strings.Join(nlist, "\n")), 0644)
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user