mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 02:04:22 +01:00
fix: resolve [pasted lines] when passing paste as arguments for command (#2333)
This commit is contained in:
@@ -489,11 +489,22 @@ func (m *editorComponent) Submit() (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
var cmds []tea.Cmd
|
var cmds []tea.Cmd
|
||||||
if strings.HasPrefix(value, "/") {
|
if strings.HasPrefix(value, "/") {
|
||||||
value = value[1:]
|
// Expand attachments in the value to get actual content
|
||||||
commandName := strings.Split(value, " ")[0]
|
expandedValue := value
|
||||||
|
attachments := m.textarea.GetAttachments()
|
||||||
|
for _, att := range attachments {
|
||||||
|
if att.Type == "text" && att.Source != nil {
|
||||||
|
if textSource, ok := att.Source.(*attachment.TextSource); ok {
|
||||||
|
expandedValue = strings.Replace(expandedValue, att.Display, textSource.Value, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expandedValue = expandedValue[1:] // Remove the "/"
|
||||||
|
commandName := strings.Split(expandedValue, " ")[0]
|
||||||
command := m.app.Commands[commands.CommandName(commandName)]
|
command := m.app.Commands[commands.CommandName(commandName)]
|
||||||
if command.Custom {
|
if command.Custom {
|
||||||
args := strings.TrimPrefix(value, command.PrimaryTrigger()+" ")
|
args := strings.TrimPrefix(expandedValue, command.PrimaryTrigger()+" ")
|
||||||
cmds = append(
|
cmds = append(
|
||||||
cmds,
|
cmds,
|
||||||
util.CmdHandler(app.SendCommand{Command: string(command.Name), Args: args}),
|
util.CmdHandler(app.SendCommand{Command: string(command.Name), Args: args}),
|
||||||
|
|||||||
Reference in New Issue
Block a user