-
Notifications
You must be signed in to change notification settings - Fork 254
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
feature: search paste support #881
Conversation
Supports pasting events to the search bar (e.g. shift-insert, ctrl-shift-v).
Codecov ReportBase: 18.55% // Head: 18.41% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #881 +/- ##
==========================================
- Coverage 18.55% 18.41% -0.14%
==========================================
Files 74 74
Lines 13698 13800 +102
==========================================
Hits 2541 2541
- Misses 11157 11259 +102
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
158a493
to
5271210
Compare
src/app/widgets/process_table.rs
Outdated
let chunk = &self.proc_search.search_state.current_search_query[start_position..]; | ||
|
||
match self | ||
.proc_search | ||
.search_state | ||
.grapheme_cursor | ||
.next_boundary( | ||
&self.proc_search.search_state.current_search_query[start_position..], | ||
start_position, | ||
) | ||
.unwrap(); | ||
.next_boundary(chunk, start_position) | ||
{ | ||
Ok(_) => {} | ||
Err(err) => match err { | ||
GraphemeIncomplete::PreContext(ctx) => { | ||
// Provide the entire string as context. Not efficient but should resolve failures. | ||
self.proc_search | ||
.search_state | ||
.grapheme_cursor | ||
.provide_context( | ||
&self.proc_search.search_state.current_search_query[0..ctx], | ||
0, | ||
); | ||
|
||
self.proc_search | ||
.search_state | ||
.grapheme_cursor | ||
.next_boundary(chunk, start_position) | ||
.unwrap(); | ||
} | ||
_ => Err(err).unwrap(), | ||
}, | ||
} | ||
} | ||
|
||
pub fn search_walk_back(&mut self, start_position: usize) { | ||
self.proc_search | ||
let chunk = &self.proc_search.search_state.current_search_query[..start_position]; | ||
match self | ||
.proc_search | ||
.search_state | ||
.grapheme_cursor | ||
.prev_boundary( | ||
&self.proc_search.search_state.current_search_query[..start_position], | ||
0, | ||
) | ||
.unwrap(); | ||
.prev_boundary(chunk, 0) | ||
{ | ||
Ok(_) => {} | ||
Err(err) => match err { | ||
GraphemeIncomplete::PreContext(ctx) => { | ||
// Provide the entire string as context. Not efficient but should resolve failures. | ||
self.proc_search | ||
.search_state | ||
.grapheme_cursor | ||
.provide_context( | ||
&self.proc_search.search_state.current_search_query[0..ctx], | ||
0, | ||
); | ||
|
||
self.proc_search | ||
.search_state | ||
.grapheme_cursor | ||
.prev_boundary(chunk, 0) | ||
.unwrap(); | ||
} | ||
_ => Err(err).unwrap(), | ||
}, | ||
} |
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.
A very quick-and-dirty way to properly fix grapheme boundary determination.
Note to self: add tests for this in the future.
939c9a2
to
17a6c12
Compare
Description
A description of the change, what it does, and why it was made. If relevant (such as any change that modifies the UI), please provide screenshots of the changes:
Adds paste support to the process search bar.
Unix support is primarily implemented using paste events. Windows falls back to keyboard inputs; to support this, I removed the key event throttler since it doesn't really seem to be necessary anymore.
This also fixes a potential issue of the grapheme cursor increment occasionally failing if it doesn't have enough context - luckily, the unicode library has a fix for that.
Issue
If applicable, what issue does this address?
Closes: #880
Testing
If relevant, please state how this was tested. All changes must be tested to work:
If this is a code change, please also indicate which platforms were tested:
Checklist
If relevant, ensure the following have been met:
cargo fmt
)README.md
, help menu, doc pages, etc.)