-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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 |
There was a problem hiding this comment.
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>" |
There was a problem hiding this comment.
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
There was a problem hiding this 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'
add
<del>
and<leftclick>
key event