Properly normalize completion labels with multi-byte characters (#25150)
Closes https://github.com/zed-industries/zed/issues/25142 Release Notes: - Fixed panics on completion with multi-byte characters input
This commit is contained in:
parent
d4414efd6f
commit
094430e5a2
1 changed files with 45 additions and 21 deletions
|
@ -8944,7 +8944,7 @@ fn ensure_uniform_list_compatible_label(label: &mut CodeLabel) {
|
|||
}
|
||||
_ => {
|
||||
new_text.push(c);
|
||||
new_idx += 1;
|
||||
new_idx += c.len_utf8();
|
||||
last_char_was_space = false;
|
||||
}
|
||||
}
|
||||
|
@ -9015,6 +9015,11 @@ fn ensure_uniform_list_compatible_label(label: &mut CodeLabel) {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use language::HighlightId;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_glob_literal_prefix() {
|
||||
assert_eq!(glob_literal_prefix(Path::new("**/*.js")), Path::new(""));
|
||||
|
@ -9048,3 +9053,22 @@ fn test_glob_literal_prefix() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multi_len_chars_normalization() {
|
||||
let mut label = CodeLabel {
|
||||
text: "myElˇ (parameter) myElˇ: {\n foo: string;\n}".to_string(),
|
||||
runs: vec![(0..6, HighlightId(1))],
|
||||
filter_range: 0..6,
|
||||
};
|
||||
ensure_uniform_list_compatible_label(&mut label);
|
||||
assert_eq!(
|
||||
label,
|
||||
CodeLabel {
|
||||
text: "myElˇ (parameter) myElˇ: { foo: string; }".to_string(),
|
||||
runs: vec![(0..6, HighlightId(1))],
|
||||
filter_range: 0..6,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue