From cf5ee577f8a437de91218c9e7afc5182db181273 Mon Sep 17 00:00:00 2001 From: Beau Reescano <25470092+jsonjunkie@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:29:06 -0500 Subject: [PATCH] handle edge case at the very last line of a file for "new_line_below" offset --- addons/godot_vim/cursor.gd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/godot_vim/cursor.gd b/addons/godot_vim/cursor.gd index 1fec6d6..e45e973 100644 --- a/addons/godot_vim/cursor.gd +++ b/addons/godot_vim/cursor.gd @@ -869,9 +869,15 @@ func cmd_insert(args: Dictionary): code_edit.get_first_non_whitespace_column(line) + int(code_edit.get_line(line).ends_with(":")) ) - code_edit.insert_line_at( - line + int(line < code_edit.get_line_count() - 1), "\t".repeat(ind) - ) + if line == (code_edit.get_line_count() - 1): + code_edit.insert_line_at( + line + int(line < code_edit.get_line_count() - 1), code_edit.get_line(line) + ) + code_edit.set_line(code_edit.get_caret_line(), "\t".repeat(ind)) + else: + code_edit.insert_line_at( + line + int(line < code_edit.get_line_count() - 1), "\t".repeat(ind) + ) move_line(+1) set_column(ind) set_mode(Mode.INSERT)