Skip to content

Commit

Permalink
fix: early return caused by ropey
Browse files Browse the repository at this point in the history
I misundertood as_str() function of RopeySlice
may fix #14
  • Loading branch information
wlh320 committed Oct 10, 2023
1 parent b044fc4 commit 279d384
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tokio::sync::RwLock;
use tower_lsp::jsonrpc::Result;
use tower_lsp::lsp_types::*;
use tower_lsp::{Client, LanguageServer};
use std::borrow::Cow;

use crate::config::{apply_setting, Config, Settings};
use crate::consts::{trigger_ptn, NT_RE};
Expand Down Expand Up @@ -149,11 +150,11 @@ impl Backend {
let re = self.regex.read().await;
let has_trigger = !self.config.read().await.trigger_characters.is_empty();
(curr_char <= rope.len_chars()).then(|| {
let slice = rope.slice(line_begin..curr_char).as_str()?;
if utils::need_to_check_trigger(has_trigger, slice) {
Input::from_str(&re, slice)
let slice = Cow::from(rope.slice(line_begin..curr_char));
if utils::need_to_check_trigger(has_trigger, &slice) {
Input::from_str(&re, &slice)
} else {
Input::from_str(&NT_RE, slice)
Input::from_str(&NT_RE, &slice)
}
})??
};
Expand Down

0 comments on commit 279d384

Please sign in to comment.