From a23576849cec7cbe3d6f9e20afc28126ccb5a784 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sun, 30 Nov 2025 03:22:39 -0500 Subject: Fix indentation for doc comments using `/**/` within other procedures --- src/server/ast.odin | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/ast.odin b/src/server/ast.odin index c6966fa..59e3de2 100644 --- a/src/server/ast.odin +++ b/src/server/ast.odin @@ -2,7 +2,6 @@ package server import "core:fmt" -import "core:log" import "core:mem" import "core:odin/ast" import "core:odin/parser" @@ -572,7 +571,26 @@ get_doc :: proc(comment: ^ast.Comment_Group, allocator: mem.Allocator) -> string tmp: string for doc in comment.list { - tmp = strings.concatenate({tmp, "\n", doc.text}, context.temp_allocator) + if strings.starts_with(doc.text, "/*") && doc.pos.column != 1 { + lines := strings.split(doc.text, "\n", context.temp_allocator) + for line, i in lines { + if i != 0 && len(line) > 0 { + column := 0 + for column < doc.pos.column - 1 { + if line[column] == '\t' || line[column] == ' ' { + column += 1 + } else { + break + } + } + tmp = strings.concatenate({tmp, "\n", line[column:]}, context.temp_allocator) + } else { + tmp = strings.concatenate({tmp, "\n", line}, context.temp_allocator) + } + } + } else { + tmp = strings.concatenate({tmp, "\n", doc.text}, context.temp_allocator) + } } if tmp != "" { -- cgit v1.2.3