Skip to content

improve popup input #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

improve popup input #90

wants to merge 2 commits into from

Conversation

nda-cunh
Copy link
Contributor

@nda-cunh nda-cunh commented Jun 12, 2025

add <del> and <leftclick> key event

@@ -239,6 +239,29 @@ def PromptFilter(wid: number, key: string): number
elseif index(keymaps['delete_prefix'], key) >= 0
line = line[cur_pos :]
cur_pos = 0
elseif key ==? "\<LeftMouse>" || key ==? "\<2-LeftMouse>"
var pos = getmousepos()
if pos.winid == wid
Copy link
Collaborator

Choose a reason for hiding this comment

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

For consistency, please use a guard clause here, and explicitly return 0 to make the intent clear, we don't handle mouse clicks that are not within this window, e.g.

if pos.winid != wid
    return 0
endif

cur_pos = 0
endif
endif
elseif key ==? "\<del>"
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/<del>/<Del>/ just for consistency, I'd probably also move this up to where the other standard, non-configurable, keypresses (i.e. <Left>, <Right>) are handled, just so there is a clean separation between handling keys and then mouse clicks

Copy link
Collaborator

@mmrwoods mmrwoods left a comment

Choose a reason for hiding this comment

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

This looks great, thanks @nda-cunh

Couple of minor suggestions just around consistency with other related code, but all works nicely for me :-)

You've also somehow ended up with tabbed indentation rather than 4 spaces. You can use the EditorConfig plugin to fix this, which is included in Vim since version 9.0.1799, see :help package-editorconfig. After installing it, I think just opening and re-saving popup.vim should do it (you can check for tabs by running :set list!)

P.S. I recommend adding these two config settings, so EditorConfig is a little less intrusive:

  let g:EditorConfig_preserve_formatoptions = 1
  let g:EditorConfig_max_line_indicator = 'fillexceeding'

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.

2 participants