Fix bad unicode calculations in do_completion (#28259)
Co-authored-by: João Marcos <marcospb19@hotmail.com> Release Notes: - Fixed a panic with completions around non-ASCII code --------- Co-authored-by: João Marcos <marcospb19@hotmail.com>
This commit is contained in:
parent
e4a6943c76
commit
448db20eaa
2 changed files with 75 additions and 17 deletions
|
@ -482,6 +482,62 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_repeat_completion_unicode_bug(cx: &mut gpui::TestAppContext) {
|
||||
VimTestContext::init(cx);
|
||||
let cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
completion_provider: Some(lsp::CompletionOptions {
|
||||
trigger_characters: Some(vec![".".to_string(), ":".to_string()]),
|
||||
resolve_provider: Some(true),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = VimTestContext::new_with_lsp(cx, true);
|
||||
|
||||
cx.set_state(
|
||||
indoc! {"
|
||||
ĩлˇк
|
||||
ĩлк
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
||||
let mut request = cx.set_request_handler::<lsp::request::Completion, _, _>(
|
||||
move |_, params, _| async move {
|
||||
let position = params.text_document_position.position;
|
||||
let mut to_the_left = position;
|
||||
to_the_left.character -= 2;
|
||||
Ok(Some(lsp::CompletionResponse::Array(vec![
|
||||
lsp::CompletionItem {
|
||||
label: "oops".to_string(),
|
||||
text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
|
||||
range: lsp::Range::new(to_the_left, position),
|
||||
new_text: "к!".to_string(),
|
||||
})),
|
||||
..Default::default()
|
||||
},
|
||||
])))
|
||||
},
|
||||
);
|
||||
cx.simulate_keystrokes("i .");
|
||||
request.next().await;
|
||||
cx.condition(|editor, _| editor.context_menu_visible())
|
||||
.await;
|
||||
cx.simulate_keystrokes("enter escape");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
ĩкˇ!к
|
||||
ĩлк
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_repeat_visual(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue