-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: improved escape
and backspace
behavior in menus
#719
Conversation
`escape` now only closes the menu, and nothing else (before it would clear search if present first). New shortcuts: - `ctrl+backspace` - Delete search query by word. - `shift+backspace` - Clear search query.
d82d0bb
to
e45672f
Compare
local word_pat, other_pat = '[^%c%s%p]+$', '[%c%s%p]+$' | ||
local init_pat = old_query:sub(#old_query):match(word_pat) and word_pat or other_pat | ||
-- First we match all same type consecutive chars at the end | ||
local tail = old_query:match(init_pat) | ||
-- If there's only one, we extend the tail with opposite type chars | ||
if tail and #tail == 1 then | ||
tail = tail .. old_query:sub(1, #old_query - #tail):match(init_pat == word_pat and other_pat or word_pat) | ||
end | ||
pos = pos - #tail |
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.
I would have expected ctrl+backspace
to always delete back to the beginning of the last word. From a quick test at least KDE things seem to consistently behave that way.
local word_pat, other_pat = '[^%c%s%p]+$', '[%c%s%p]+$' | |
local init_pat = old_query:sub(#old_query):match(word_pat) and word_pat or other_pat | |
-- First we match all same type consecutive chars at the end | |
local tail = old_query:match(init_pat) | |
-- If there's only one, we extend the tail with opposite type chars | |
if tail and #tail == 1 then | |
tail = tail .. old_query:sub(1, #old_query - #tail):match(init_pat == word_pat and other_pat or word_pat) | |
end | |
pos = pos - #tail | |
pos = old_query:find('[^%c%s%p]*[%c%s%p]*$') - 1 |
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.
Apparently that's not the case for vscode, it behaves like your original code. It doesn't really matter i guess.
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.
Yeah I've tried making it like vscode, which is how I expected it to work from the beginning.
For example, if I have a string like:
abc.--
I'd want ctrl+backspace
to end before c
, not delete the whole string.
vscode has a bit more conditional behaviors, but I didn't want to make it that complex.
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.
I would have expected
ctrl+backspace
to always delete back to the beginning of the last word.
This behavior is iconsistent across applications, unfortunately. Sublime Text, for example, deletes until the next boundary between word characters, punctuation, or whitespace.
escape
now only closes the menu, and nothing else (before it would clear search if present first).New shortcuts:
ctrl+backspace
- Delete search query by word.shift+backspace
- Clear search query.