aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/shellwords.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/helix-core/src/shellwords.rs b/helix-core/src/shellwords.rs
index 9475f5e5..0883eb91 100644
--- a/helix-core/src/shellwords.rs
+++ b/helix-core/src/shellwords.rs
@@ -129,8 +129,9 @@ impl<'a> From<&'a str> for Shellwords<'a> {
DquoteEscaped => Dquoted,
};
- if i >= input.len() - 1 && end == 0 {
- end = i + 1;
+ let c_len = c.len_utf8();
+ if i == input.len() - c_len && end == 0 {
+ end = i + c_len;
}
if end > 0 {
@@ -333,4 +334,17 @@ mod test {
assert_eq!(Shellwords::from(":o a").parts(), &[":o", "a"]);
assert_eq!(Shellwords::from(":o a\\ ").parts(), &[":o", "a\\"]);
}
+
+ #[test]
+ fn test_multibyte_at_end() {
+ assert_eq!(Shellwords::from("π’€€").parts(), &["π’€€"]);
+ assert_eq!(
+ Shellwords::from(":sh echo π’€€").parts(),
+ &[":sh", "echo", "π’€€"]
+ );
+ assert_eq!(
+ Shellwords::from(":sh echo π’€€ hello worldπ’€€").parts(),
+ &[":sh", "echo", "π’€€", "hello", "worldπ’€€"]
+ );
+ }
}