Skip to content

fix(ui): support clipboard paste in filter and command inputs#202

Open
nick4eva wants to merge 1 commit into
clawscli:mainfrom
nick4eva:add-ability-to-paste-search-string-from-clipboard
Open

fix(ui): support clipboard paste in filter and command inputs#202
nick4eva wants to merge 1 commit into
clawscli:mainfrom
nick4eva:add-ability-to-paste-search-string-from-clipboard

Conversation

@nick4eva

Copy link
Copy Markdown
Contributor

Filter views only routed tea.KeyPressMsg to their textinput, so bracketed paste (Ctrl+Shift+V, tmux paste) was dropped and the textinput's built-in Ctrl+V never received its clipboard-read result.

Forward paste and other textinput-bound messages to the focused filter input in the resource browser, service browser, log view, tag search view and multi selector, and accept tea.PasteMsg in command mode.

Closes #201

Filter views only routed tea.KeyPressMsg to their textinput, so
bracketed paste (Ctrl+Shift+V, tmux paste) was dropped and the
textinput's built-in Ctrl+V never received its clipboard-read result.

Forward paste and other textinput-bound messages to the focused filter
input in the resource browser, service browser, log view, tag search
view and multi selector, and accept tea.PasteMsg in command mode.

@yimsk yimsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding paste support and the accompanying tests. Overall, this looks like a good change.

Two things stood out while reviewing it:

  1. The clipboard result from Ctrl+V does not return to the command input in command mode.
  2. Mouse-wheel scrolling stops working in LogView while the filter is active.

Could you please take a look at these two cases?

Comment thread internal/app/app.go
keyMsg, ok := msg.(tea.KeyPressMsg)
if !ok {
switch msg.(type) {
case tea.KeyPressMsg, tea.PasteMsg:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Ctrl+V still won't paste into the command input.

In Bubbles v2.1.0, the result of the clipboard read is returned as the unexported textinput.pasteMsg, rather than tea.PasteMsg.

Since this branch only forwards tea.KeyPressMsg and tea.PasteMsg to commandInput.Update, textinput.pasteMsg falls through to the current view and never reaches the command input.

One concrete way to address this would be to add a clipboard-read tea.Cmd under internal/clipboard that returns a public tea.PasteMsg on success, and intercept Ctrl+V in CommandInput.Update before delegating to textInput.Update. This would reuse the existing handleCommandModeMsg branch without depending on Bubbles' unexported message type.

It would also be helpful to add a test that executes the command returned by Ctrl+V and feeds its result back into App.Update.

Comment thread internal/view/log_view.go

// Route paste and other textinput-bound messages to the active filter.
if v.filterActive {
return v.updateFilterInput(msg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mouse-wheel scrolling no longer works while the filter is active.

tea.MouseWheelMsg also reaches this branch and returns through filterInput.Update before it can reach the viewport. Before this change, mouse-wheel messages were passed to v.vp.Model.Update.

Could you route mouse-wheel messages to the viewport before this fallback? A regression test for scrolling while the filter is active would also be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't paste from clipboard into the search filter

2 participants