From 9ba73ff740f3dc35a0aadd958535dea1cf7977b7 Mon Sep 17 00:00:00 2001 From: Hawtian Wang Date: Thu, 22 Feb 2024 18:13:12 +0800 Subject: [PATCH 1/2] fix: find raw_input from the end --- src/lsp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lsp.rs b/src/lsp.rs index e9624aa..486b4af 100644 --- a/src/lsp.rs +++ b/src/lsp.rs @@ -195,7 +195,7 @@ impl Backend { // prevent deleting puncts before real pinyin input let real_offset = new_offset + raw_input - .and_then(|rime_raw_input| new_input.borrow_pinyin().find(&rime_raw_input)) + .and_then(|rime_raw_input| new_input.borrow_pinyin().rfind(&rime_raw_input)) .unwrap_or(0); // candidates to completions From a8b19cd9f6db45ec373758356ee2a5c132386d40 Mon Sep 17 00:00:00 2001 From: Hawtian Wang Date: Thu, 22 Feb 2024 22:32:03 +0800 Subject: [PATCH 2/2] fix: check if `raw_input` is empty string --- src/lsp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lsp.rs b/src/lsp.rs index 486b4af..d45a2c2 100644 --- a/src/lsp.rs +++ b/src/lsp.rs @@ -195,6 +195,7 @@ impl Backend { // prevent deleting puncts before real pinyin input let real_offset = new_offset + raw_input + .and_then(utils::option_string) .and_then(|rime_raw_input| new_input.borrow_pinyin().rfind(&rime_raw_input)) .unwrap_or(0);