summaryrefslogtreecommitdiff
path: root/helix-core/src/syntax.rs
diff options
context:
space:
mode:
authorPascal Kuthe2024-02-26 07:45:20 +0000
committerGitHub2024-02-26 07:45:20 +0000
commitcd02976fa3a55c2c1f01b95c40d178061968f797 (patch)
tree707df0a4fb93fa7c8773ba59a85259835deb166e /helix-core/src/syntax.rs
parentc68ec92c5e1bd3a2bf402fb583de23693f59b722 (diff)
switch to regex-cursor (#9422)
Diffstat (limited to 'helix-core/src/syntax.rs')
-rw-r--r--helix-core/src/syntax.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index a9344448..0d8559ca 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -12,6 +12,7 @@ use arc_swap::{ArcSwap, Guard};
use bitflags::bitflags;
use globset::GlobSet;
use hashbrown::raw::RawTable;
+use helix_stdx::rope::{self, RopeSliceExt};
use slotmap::{DefaultKey as LayerId, HopSlotMap};
use std::{
@@ -1961,11 +1962,16 @@ impl HighlightConfiguration {
node_slice
};
- static SHEBANG_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(SHEBANG).unwrap());
+ static SHEBANG_REGEX: Lazy<rope::Regex> =
+ Lazy::new(|| rope::Regex::new(SHEBANG).unwrap());
injection_capture = SHEBANG_REGEX
- .captures(&Cow::from(lines))
- .map(|cap| InjectionLanguageMarker::Shebang(cap[1].to_owned()))
+ .captures_iter(lines.regex_input())
+ .map(|cap| {
+ let cap = lines.byte_slice(cap.get_group(1).unwrap().range());
+ InjectionLanguageMarker::Shebang(cap.into())
+ })
+ .next()
} else if index == self.injection_content_capture_index {
content_node = Some(capture.node);
}