From be40c6cb826fa9252cf90865bca74b7fec1a6da8 Mon Sep 17 00:00:00 2001 From: Colin Kiama Date: Sun, 30 Jun 2024 14:33:18 +0100 Subject: [PATCH] Fix cursor positioning when column number is not set when go to line feature is used --- src/Widgets/SourceView.vala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Widgets/SourceView.vala b/src/Widgets/SourceView.vala index a9fecd3ed..2759b98bf 100644 --- a/src/Widgets/SourceView.vala +++ b/src/Widgets/SourceView.vala @@ -320,7 +320,9 @@ namespace Scratch.Widgets { public void go_to_line (int line, int offset = 0) { Gtk.TextIter it; buffer.get_iter_at_line (out it, line - 1); - it.forward_chars (offset); + // Ensures offset is set to start of line when column is not set + // offset = column - 1 + it.forward_chars (offset == -1 ? 0 : offset); scroll_to_iter (it, 0, false, 0, 0); buffer.place_cursor (it); }