diff options
Diffstat (limited to 'support/texlab/crates/texlab/src/util/cursor.rs')
-rw-r--r-- | support/texlab/crates/texlab/src/util/cursor.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/support/texlab/crates/texlab/src/util/cursor.rs b/support/texlab/crates/texlab/src/util/cursor.rs index b03036386c..a39d0e7bf7 100644 --- a/support/texlab/crates/texlab/src/util/cursor.rs +++ b/support/texlab/crates/texlab/src/util/cursor.rs @@ -241,18 +241,13 @@ impl<'a, T> CursorContext<'a, T> { pub fn find_environment(&self) -> Option<(latex::Key, latex::Key)> { let token = self.cursor.as_tex()?; - - for env in token + let env = token .parent_ancestors() - .filter_map(latex::Environment::cast) - { - let beg = env.begin()?.name()?.key()?; - let end = env.end()?.name()?.key()?; - - return Some((beg, end)); - } + .find_map(latex::Environment::cast)?; - None + let beg = env.begin()?.name()?.key()?; + let end = env.end()?.name()?.key()?; + Some((beg, end)) } pub fn find_curly_group_word(&self) -> Option<(String, TextRange, latex::CurlyGroupWord)> { |