Skip to content

Commit 1a057b7

Browse files
k8s-1claude
andcommitted
refactor: replace comment_re closure with nested fn comment_text in comments_above
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a037309 commit 1a057b7

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
### 🚜 Refactor
44

55
- Inline is_definition/is_reference helpers and simplify completion guards
6+
- Remove unreachable unwrap_or in completion symbol lookup
7+
- Split find_occurrences_within_tree into variable and function helpers
8+
- Replace comment_re closure with nested fn comment_text in comments_above
9+
10+
### ⚙️ Miscellaneous Tasks
11+
12+
- Format and changelog
613
## [0.2.7] - 2026-05-29
714

815
### 📚 Documentation

src/analyser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,18 @@ impl Analyser {
326326
#[must_use]
327327
pub fn comments_above(&self, uri: &str, line: u32) -> Option<String> {
328328
let doc = self.docs.get(uri)?;
329+
fn comment_text(l: &str) -> Option<String> {
330+
let rest = l.trim_start().strip_prefix('#')?.trim_start();
331+
Some(rest.trim_end().to_string())
332+
}
333+
329334
let lines: Vec<&str> = doc.source.lines().collect();
330335
let mut block = Vec::new();
331-
let comment_re = |l: &str| -> Option<String> {
332-
let trimmed = l.trim_start();
333-
let rest = trimmed.strip_prefix('#')?.trim_start();
334-
Some(rest.trim_end().to_string())
335-
};
336336

337337
let mut idx = line.saturating_sub(1) as usize;
338338
loop {
339339
let l = lines.get(idx)?;
340-
match comment_re(l) {
340+
match comment_text(l) {
341341
Some(c) => {
342342
block.push(c);
343343
if idx == 0 {

src/util/declarations.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,12 @@ fn find_variable_occurrences<'a>(
371371
start: Option<Position>,
372372
) -> Vec<Range> {
373373
let mut nodes = Vec::new();
374-
collect_typed_nodes(base_node, &["variable_name", "word"], effective_start, &mut nodes);
374+
collect_typed_nodes(
375+
base_node,
376+
&["variable_name", "word"],
377+
effective_start,
378+
&mut nodes,
379+
);
375380

376381
let mut ignored_ranges: Vec<Range> = Vec::new();
377382
let mut result: Vec<Range> = Vec::new();

0 commit comments

Comments
 (0)