Skip to content

Commit e799976

Browse files
committed
Extract a method CustomCommand.GetDescription
We'll reuse it in the next commit.
1 parent f93948c commit e799976

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pkg/config/user_config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,14 @@ type CustomCommand struct {
640640
After *CustomCommandAfterHook `yaml:"after"`
641641
}
642642

643+
func (c *CustomCommand) GetDescription() string {
644+
if c.Description != "" {
645+
return c.Description
646+
}
647+
648+
return c.Command
649+
}
650+
643651
type CustomCommandPrompt struct {
644652
// One of: 'input' | 'menu' | 'confirm' | 'menuFromCommand'
645653
Type string `yaml:"type"`

pkg/gui/services/custom_commands/keybinding_creator.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,13 @@ func (self *KeybindingCreator) call(customCommand config.CustomCommand, handler
3434
return nil, err
3535
}
3636

37-
description := customCommand.Description
38-
if description == "" {
39-
description = customCommand.Command
40-
}
41-
4237
return lo.Map(viewNames, func(viewName string, _ int) *types.Binding {
4338
return &types.Binding{
4439
ViewName: viewName,
4540
Key: keybindings.GetKey(customCommand.Key),
4641
Modifier: gocui.ModNone,
4742
Handler: handler,
48-
Description: description,
43+
Description: customCommand.GetDescription(),
4944
}
5045
}), nil
5146
}

0 commit comments

Comments
 (0)