mirror of
https://github.com/charmbracelet/crush.git
synced 2025-08-02 05:20:46 +03:00
Merge pull request #221 from charmbracelet/bugfix/filepicker-in-cwd
fix: start filepicker in cwd instead of os.Homedir
This commit is contained in:
@@ -92,6 +92,11 @@ func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
|
||||
return app, nil
|
||||
}
|
||||
|
||||
// Config returns the application configuration.
|
||||
func (app *App) Config() *config.Config {
|
||||
return app.config
|
||||
}
|
||||
|
||||
// RunNonInteractive handles the execution flow when a prompt is provided via CLI flag.
|
||||
func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
|
||||
slog.Info("Running in non-interactive mode")
|
||||
|
||||
@@ -72,7 +72,7 @@ var DeleteKeyMaps = DeleteAttachmentKeyMaps{
|
||||
),
|
||||
DeleteAllAttachments: key.NewBinding(
|
||||
key.WithKeys("r"),
|
||||
key.WithHelp("ctrl+r+r", "delete all attchments"),
|
||||
key.WithHelp("ctrl+r+r", "delete all attachments"),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ func (k EditorKeyMap) KeyBindings() []key.Binding {
|
||||
k.SendMessage,
|
||||
k.OpenEditor,
|
||||
k.Newline,
|
||||
AttachmentsKeyMaps.AttachmentDeleteMode,
|
||||
AttachmentsKeyMaps.DeleteAllAttachments,
|
||||
AttachmentsKeyMaps.Escape,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,22 @@ type model struct {
|
||||
help help.Model
|
||||
}
|
||||
|
||||
func NewFilePickerCmp() FilePicker {
|
||||
func NewFilePickerCmp(workingDir string) FilePicker {
|
||||
t := styles.CurrentTheme()
|
||||
fp := filepicker.New()
|
||||
fp.AllowedTypes = []string{".jpg", ".jpeg", ".png"}
|
||||
fp.CurrentDirectory, _ = os.UserHomeDir()
|
||||
|
||||
if workingDir != "" {
|
||||
fp.CurrentDirectory = workingDir
|
||||
} else {
|
||||
// Fallback to current working directory, then home directory
|
||||
if cwd, err := os.Getwd(); err == nil {
|
||||
fp.CurrentDirectory = cwd
|
||||
} else {
|
||||
fp.CurrentDirectory, _ = os.UserHomeDir()
|
||||
}
|
||||
}
|
||||
|
||||
fp.ShowPermissions = false
|
||||
fp.ShowSize = false
|
||||
fp.AutoHeight = false
|
||||
|
||||
@@ -838,6 +838,18 @@ func (p *chatPage) Help() help.KeyMap {
|
||||
key.WithKeys("ctrl+v"),
|
||||
key.WithHelp("ctrl+v", "open editor"),
|
||||
),
|
||||
key.NewBinding(
|
||||
key.WithKeys("ctrl+r"),
|
||||
key.WithHelp("ctrl+r+{i}", "delete attachment at index i"),
|
||||
),
|
||||
key.NewBinding(
|
||||
key.WithKeys("ctrl+r", "r"),
|
||||
key.WithHelp("ctrl+r+r", "delete all attachments"),
|
||||
),
|
||||
key.NewBinding(
|
||||
key.WithKeys("esc"),
|
||||
key.WithHelp("esc", "cancel delete mode"),
|
||||
),
|
||||
})
|
||||
}
|
||||
shortList = append(shortList,
|
||||
|
||||
@@ -204,7 +204,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return a, util.CmdHandler(dialogs.CloseDialogMsg{})
|
||||
}
|
||||
return a, util.CmdHandler(dialogs.OpenDialogMsg{
|
||||
Model: filepicker.NewFilePickerCmp(),
|
||||
Model: filepicker.NewFilePickerCmp(a.app.Config().WorkingDir()),
|
||||
})
|
||||
// Permissions
|
||||
case pubsub.Event[permission.PermissionRequest]:
|
||||
|
||||
Reference in New Issue
Block a user