sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
804 stars 39 forks source link

paste_from_history should select an item #2532

Open haferburg opened 5 years ago

haferburg commented 5 years ago

Problem description

When I use paste_from_history, no item is selected. If I simply press Return, nothing happens. In order to select the first item, I would need press down. To select the second item, press down twice, etc. I don't know if this is OS specific.

Preferred solution

I find that Visual Assist found a nice solution. ctrl+v is paste, and pastes the last item from the copy history. ctrl+shift+v followed by return pastes the second last item from the copy history. This enables a nice workflow for two items: Copy two items a and b with ctrl+c, then ctrl+shift+v followed by return twice in a row to paste a followed by b.

Another nice feature is that you can select items by hotkey from the ctrl+shift+v popup. I believe the first 9 items use numbers 1-9, the next items use letters a-z. These hotkeys are displayed next to the items.

2018-12-25 23_49_40-dkmv debugging - microsoft visual studio

It would be nice if the view.show_popup_menu API would allow hotkeys and item pre-selection. There is a flags parameter, but it's unused.

Alternatives

Select the first or second item. Anything is better than nothing.

Additional Information (optional)

Windows 7 x64, ST3 build 3184.

haferburg commented 5 years ago

Ugly workaround using AutoHotkey:

#IfWinActive ahk_exe sublime_text.exe
^+v::
  Send ^+v
  Send {Down}
  Send {Down}
return
#IfWinActive
FichteFoll commented 5 years ago

I wonder about this. The paste_from_history command uses the View.show_popup_menu API to open a popup menu that the user can select from. This is just a custom context menu and adheres to various UI standards. E.g. when hovering over items and then leaving the menu, no item is selected.

However, when this is opened as a direct cause of a key press (i.e. through a key binding), I believe it makes sense to pre-select an item. The auto-complete panel works the same.

haferburg commented 5 years ago

@FichteFoll Unfortunately you can't interact with the popup menu programmatically. There's the chain of command plugin, but I don't think you can use it to send the down key to the menu.