From 2e9147c47d2df3ff67b0422cc21ba828d9589ac0 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Tue, 13 May 2025 09:11:42 +0200 Subject: [PATCH] Fix Command_Open jumping to beginning every time --- data/init.lua | 2 +- src/text_editor/generated.cpp | 1 - src/text_editor/lua_api.cpp | 12 ++++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/data/init.lua b/data/init.lua index c91665f..f956f44 100644 --- a/data/init.lua +++ b/data/init.lua @@ -67,7 +67,7 @@ function IsAlpha(a) end function SkipLineAndColumn(s) - local line, col = "1", "1" + local line, col = "-1", "-1" function parse_line_and_column(line_and_col, delimiter) ic, jc = line_and_col:find(delimiter) diff --git a/src/text_editor/generated.cpp b/src/text_editor/generated.cpp index 2a92556..4de62c3 100644 --- a/src/text_editor/generated.cpp +++ b/src/text_editor/generated.cpp @@ -381,7 +381,6 @@ function KeybindsFKeys(e) if e.key == FKeySDLK[i] then local cmdline = FKey[i] if type(cmdline) == "function" then cmdline = FKey[i]() end - Print(cmdline) Cmd { working_dir = GetWorkDir(), kind = "console", cmd = cmdline } return true end diff --git a/src/text_editor/lua_api.cpp b/src/text_editor/lua_api.cpp index 3795735..ada1f3d 100644 --- a/src/text_editor/lua_api.cpp +++ b/src/text_editor/lua_api.cpp @@ -320,8 +320,16 @@ OnOpenResult CallOnOpen(String path, String meta) { result.cmd = cmd; result.working_dir = working_dir; result.file_path = file_path; - if (col_string.len) result.col = strtoll(col_string.data, NULL, 10); - if (line_string.len) result.line = strtoll(line_string.data, NULL, 10); + if (col_string.len) { + result.col = strtoll(col_string.data, NULL, 10); + } else { + result.col = -1; + } + if (line_string.len) { + result.line = strtoll(line_string.data, NULL, 10); + } else { + result.line = -1; + } result.kind = kind; return result;