-
-
Notifications
You must be signed in to change notification settings - Fork 786
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: The search overlay accepts IME composed input #5564
Feature: The search overlay accepts IME composed input #5564
Conversation
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.
Thanks for this! A couple of minor comments!
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
wezterm-gui/src/overlay/copy.rs
Outdated
let s = std::str::from_utf8(buf).map_err(|err| { | ||
std::io::Error::new(std::io::ErrorKind::Other, format!("invalid UTF-8: {err:#}")) | ||
})?; | ||
render.pattern.push_str(s); |
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.
actually, it might be possible to do this:
render.pattern.write(buf)?;
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.
emm, IDE hint
Type mismatch [E0308] expected `&mut TiffWriter<_>`, but found `&[u8]`
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.
[MEMO]: After accepting PR #5416, render.search_line.insert_text(s)
should be used here instead.
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.
Would you like to rebase and update this PR to do that now that #5416 is merged?
termwiz/src/lineedit/buffer.rs
Outdated
self.cursor | ||
} | ||
} | ||
Movement::EndOfLine => self.line.len(), |
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.
EndOfLine
is simply set to self.line.len()
BTW: self.cursor
is a byte index, and the index(storage) is not related to graphemes(visual), so perhaps calling it cursor_index
would be clearer.
@Mrreadiness @wez
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.
emm... I think the crash might be caused by self.line.len().saturating_sub(1)
, as the offset is not at the boundary of a Unicode character, which causes cursor.next_boundary(&self.line, 0)
to panic. Just like StartOfLine
, EndOfLine
doesn't need any extra calculation; simply using self.line.len()
is the most straightforward approach.
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.
Hmm, what I think we should do here is:
- Remove this change from this PR, as it has a different thesis from the rest of the PR
- Make a new PR that adds a couple of unit tests around is EndOfLine operation, and fixes the problematic case
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.
reverted
This reverts commit f5ca810.
Thank you! |
* Feature: The search overlay accepts IME composed input * use LineEditBuffer Co-authored-by: Wez Furlong <wez@wezfurlong.org>
#5333 (comment)
Based on other Writers, I wrote a writer for the search overlay.
The good news is that it appears to be working well.
However, as I am relatively new to Rust, there might be some bad code. I would greatly appreciate it if you could review the code for me.
Thank you. @wez