This version avoids the problems of the first two versions (but still does not implement the paste action itself). I apply it to two situations: whether copying screen content into the "copy-mode-vi" mode search box or the line editor of the "command-prompt" mode interactive window, it is based on the same logic: define an additional @buffer_content to store the latest buffer variable, it will be automatically pasted into the currently executing line editor in its original form. You can edit and submit the content normally for further processing.
Version
Here is a related link. The method it provides is the same as the method I use. It has the advantage of automatic copying selection since it must work under the copy-mode (via send-keys), which implementation still requires caching to a custom tmux variable on my machine and should use the "-I" interface. The relevant version shows below Run arbitrary command in tmux copy mode
Version 4
A
bind-key -T copy-mode-vi \\ send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -I '#{@buffer_command}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run 'tmux set -u "@buffer_command"'
bind-key -T copy-mode-vi ! send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -p '>' -I '#{@buffer_command}' \; \
run 'tmux set -u "@buffer_command"'
A related discussion
How can I search within the output buffer of a tmux shell?