Skip to content

Commit

Permalink
Merge pull request #517 from FourteenBrush/master
Browse files Browse the repository at this point in the history
Fixes #508
  • Loading branch information
DanielGavin authored Sep 28, 2024
2 parents d24a9c8 + 6de56ab commit 0f20cb9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/odin/printer/printer.odin
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,18 @@ build_disabled_lines_info :: proc(p: ^Printer) {

for group in p.comments {
for comment in group.list {
comment_text, _ := strings.replace_all(comment.text[:], " ", "", context.temp_allocator)

if strings.contains(comment_text, "//odinfmt:disable") {
if !strings.starts_with(comment.text, "//") do continue
comment_text := strings.trim_left_space(comment.text[len("//"):])

if !strings.starts_with(comment_text, "odinfmt:") do continue
action := strings.trim_space(comment_text[len("odinfmt:"):])

if action == "disable" {
found_disable = true
empty = true
disable_position = comment.pos
} else if strings.contains(comment_text, "//odinfmt:enable") && found_disable {
} else if found_disable && action == "enable" {
begin := disable_position.offset - (comment.pos.column - 1)
end := comment.pos.offset + len(comment.text)

Expand All @@ -146,7 +151,7 @@ build_disabled_lines_info :: proc(p: ^Printer) {
empty = empty,
}

for line := disable_position.line; line <= comment.pos.line; line += 1 {
for line in disable_position.line..=comment.pos.line {
p.disabled_lines[line] = disabled_info
}

Expand Down

0 comments on commit 0f20cb9

Please sign in to comment.