Moved the plugin directory
All checks were successful
Release Build / build (push) Successful in 1m53s
All checks were successful
Release Build / build (push) Successful in 1m53s
This commit is contained in:
parent
add62fbfa0
commit
9751be125e
5 changed files with 47 additions and 12 deletions
27
app.go
27
app.go
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -96,10 +97,11 @@ func (a *App) loadPluginsFrom(dir string) int {
|
|||
func (a *App) startup(ctx context.Context) {
|
||||
a.baseCtx = ctx
|
||||
|
||||
dir, err := pluginDir()
|
||||
dir, err := ensurePluginDir()
|
||||
if err != nil {
|
||||
log.Printf("cannot determine plugin directory: %v", err)
|
||||
a.setUCLInst(newUCLInst(newPluginFilters()), nil)
|
||||
plugins := newPluginFilters()
|
||||
plugins.recordError(err)
|
||||
a.setUCLInst(newUCLInst(plugins), plugins)
|
||||
return
|
||||
}
|
||||
a.loadPluginsFrom(dir)
|
||||
|
|
@ -114,11 +116,11 @@ func (a *App) domReady(ctx context.Context) {
|
|||
// ReloadPlugins discards the current plugin filters and UCL interpreter, rescans the plugin
|
||||
// directory, and refreshes the command palette. Invoked from the File menu.
|
||||
func (a *App) ReloadPlugins() {
|
||||
dir, err := pluginDir()
|
||||
dir, err := ensurePluginDir()
|
||||
if err != nil {
|
||||
_, _, ctx := a.current()
|
||||
runtime.EventsEmit(ctx, "set-statusbar-message", SetStatusbarMessage{
|
||||
Message: fmt.Sprintf("Cannot determine plugin directory: %v", err),
|
||||
Message: fmt.Sprintf("Cannot prepare plugin directory: %v", err),
|
||||
Error: true,
|
||||
})
|
||||
return
|
||||
|
|
@ -131,6 +133,21 @@ func (a *App) ReloadPlugins() {
|
|||
a.reportPluginStatus(count, true)
|
||||
}
|
||||
|
||||
// openPluginDir opens the plugin directory using the specified macOS application.
|
||||
func (a *App) openPluginDir(application string) {
|
||||
dir, err := ensurePluginDir()
|
||||
if err == nil {
|
||||
err = exec.Command("/usr/bin/open", "-a", application, dir).Run()
|
||||
}
|
||||
if err != nil {
|
||||
_, _, ctx := a.current()
|
||||
runtime.EventsEmit(ctx, "set-statusbar-message", SetStatusbarMessage{
|
||||
Message: fmt.Sprintf("Cannot open plugins in %s: %v", application, err),
|
||||
Error: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// reportPluginStatus shows plugin load errors in the status bar. If there are no errors and
|
||||
// reloaded is true, a confirmation message is shown instead.
|
||||
func (a *App) reportPluginStatus(filterCount int, reloaded bool) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue