mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Match stdlib strip_prefix return value
This commit is contained in:
parent
30fbd4280d
commit
7dc0446c5c
2 changed files with 4 additions and 7 deletions
|
@ -291,7 +291,7 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
|
|||
codepoint,
|
||||
})?
|
||||
} else if codepoint.is_none() && key_name.starts_with('F') && key_name.len() <= 3 {
|
||||
let num = key_name.strip_prefix('F');
|
||||
let num = key_name.strip_prefix('F').unwrap();
|
||||
let codepoint = match fish_wcstoi(num) {
|
||||
Ok(n) if (1..=12).contains(&n) => function_key(u32::try_from(n).unwrap()),
|
||||
_ => {
|
||||
|
|
|
@ -277,14 +277,11 @@ pub trait WExt {
|
|||
iter_prefixes_iter(prefix.chars(), self.as_char_slice().iter().copied())
|
||||
}
|
||||
|
||||
fn strip_prefix<Prefix: IntoCharIter>(&self, prefix: Prefix) -> &wstr {
|
||||
fn strip_prefix<Prefix: IntoCharIter>(&self, prefix: Prefix) -> Option<&wstr> {
|
||||
let iter = prefix.chars();
|
||||
let prefix_len = iter.clone().count();
|
||||
if iter_prefixes_iter(iter, self.as_char_slice().iter().copied()) {
|
||||
self.slice_from(prefix_len)
|
||||
} else {
|
||||
self.slice_from(0)
|
||||
}
|
||||
iter_prefixes_iter(iter, self.as_char_slice().iter().copied())
|
||||
.then(|| self.slice_from(prefix_len))
|
||||
}
|
||||
|
||||
/// \return whether we end with a given Suffix.
|
||||
|
|
Loading…
Reference in a new issue