From 4e8987101dc60a162515ec5e4acee8aa92ef7684 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 30 Jan 2026 19:34:05 +0100 Subject: [PATCH] Addressing the C:/Program Files (x86)/ situation --- src/text_editor/buffer.cpp | 5 ---- src/text_editor/ui.cpp | 56 ++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/text_editor/buffer.cpp b/src/text_editor/buffer.cpp index e966e87..ae9bb6a 100644 --- a/src/text_editor/buffer.cpp +++ b/src/text_editor/buffer.cpp @@ -309,11 +309,6 @@ API Int GetWordEnd(Buffer *buffer, Int pos) { return pos; } -bool IsOpenBoundary(char c) { - bool result = c == 0 || IsParen(c) || IsBrace(c) || c == ':' || c == '\t' || c == '\n' || c == '"' || c == '\''; - return result; -} - API bool IsLoadWord(char16_t w) { bool result = w == u'-' || w == u'/' || w == u'\\' || w == u':' || w == u'$' || w == u'_' || w == u'.' || w == u'!' || w == u'@'; if (!result) { diff --git a/src/text_editor/ui.cpp b/src/text_editor/ui.cpp index 0a9e389..47f84cd 100644 --- a/src/text_editor/ui.cpp +++ b/src/text_editor/ui.cpp @@ -212,6 +212,11 @@ void MouseLoadWord(Event event, ResolveOpenMeta meta = ResolveOpenMeta_Normal) { } } +bool IsOpenBoundary(char c) { + bool result = c == 0 || IsBrace(c) || c == ':' || c == '\t' || c == '\n' || c == '"' || c == '\''; + return result; +} + ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpenMeta meta) { ResolvedOpen result = {}; path = Trim(path); @@ -285,7 +290,48 @@ ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpen } path = {pstart.data, (Int)(p.data - pstart.data)}; - if (At(p, 0) == ':') { + // @todo: verify! + // For (LINE:COLUMN): error: - we can either backtrack at the end since we are including + // the parenthesis and whitespace or alternatively we can look for patterns on every + // character move in the loop... For now let's do backtracking. This doesn't handle all paths + // but not sure if that's even what we want. ALL paths is hard. + { + Int i = path.len - 1; + if (At(path, i) == ')') { + i -= 1; + + Int end = i; + while (IsDigit(At(path, i))) { + i -= 1; + } + Int start = i; + String b = {path.data + 1 + start, (end - start)}; + + if (At(path, i) == ')') { + i -= 1; + path.len = i + 1; + result.line = strtoll(b.data, NULL, 10); + } else if (At(path, i) == ',') { + i -= 1; + + end = i; + while (IsDigit(At(path, i))) { + i -= 1; + } + start = i; + String a = {path.data + 1 + start, (end - start)}; + + if (At(path, i) == '(') { + i -= 1; + path.len = i + 1; + result.line = strtoll(a.data, NULL, 10); + result.col = strtoll(b.data, NULL, 10); + } + } + } + } + + if (result.line == 0 && At(p, 0) == ':') { p = Skip(p, 1); result.line = SkipInt(&p); if (At(p, 0) == ':') { @@ -293,14 +339,6 @@ ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpen Int b = SkipInt(&p); result.col = b; } - } else if (At(p, 0) == '(') { - p = Skip(p, 1); - result.line = SkipInt(&p); - if (At(p, 0) == ',') { - p = Skip(p, 1); - Int b = SkipInt(&p); - result.col = b; - } } Buffer *existing_buffer = GetBuffer(path, NULL);