aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-09-28 13:18:45 +0200
committerGitHub <noreply@github.com>2024-09-28 13:18:45 +0200
commit0f20cb93208f3f1505ee5d1844f8df427006e9f5 (patch)
treebaa8a3fe154e385ae0b30e60e1d4bbd1519d8ed9 /src
parentd24a9c8d500a30171374226044b6f3e577ee327d (diff)
parent6de56ab3f1022a061f38de6d270293e7b6097173 (diff)
Merge pull request #517 from FourteenBrush/master
Fixes #508
Diffstat (limited to 'src')
-rw-r--r--src/odin/printer/printer.odin13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/odin/printer/printer.odin b/src/odin/printer/printer.odin
index 8fb8baf..74f5853 100644
--- a/src/odin/printer/printer.odin
+++ b/src/odin/printer/printer.odin
@@ -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)
@@ -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
}