aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/theme.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/theme.rs')
-rw-r--r--helix-view/src/theme.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index 125725e0..ce061bab 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -314,10 +314,23 @@ impl Theme {
&self.scopes
}
- pub fn find_scope_index(&self, scope: &str) -> Option<usize> {
+ pub fn find_scope_index_exact(&self, scope: &str) -> Option<usize> {
self.scopes().iter().position(|s| s == scope)
}
+ pub fn find_scope_index(&self, mut scope: &str) -> Option<usize> {
+ loop {
+ if let Some(highlight) = self.find_scope_index_exact(scope) {
+ return Some(highlight);
+ }
+ if let Some(new_end) = scope.rfind('.') {
+ scope = &scope[..new_end];
+ } else {
+ return None;
+ }
+ }
+ }
+
pub fn is_16_color(&self) -> bool {
self.styles.iter().all(|(_, style)| {
[style.fg, style.bg]