Browse Source

Script Editor: maintain cursor column after duplicate a line

Franklin Sobrinho 9 năm trước cách đây
mục cha
commit
b3ce127e31
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      tools/editor/plugins/script_editor_plugin.cpp

+ 3 - 1
tools/editor/plugins/script_editor_plugin.cpp

@@ -1137,12 +1137,14 @@ void ScriptEditor::_menu_option(int p_option) {
 					return;
 				int line = tx->cursor_get_line();
 				int next_line = line + 1;
+				int column = tx->cursor_get_column();
 
-				if (line == tx->get_line_count() - 1 || next_line >= tx->get_line_count())
+				if (line >= tx->get_line_count() - 1)
 					tx->set_line(line, tx->get_line(line) + "\n");
 
 				String line_clone = tx->get_line(line);
 				tx->insert_at(line_clone, next_line);
+				tx->cursor_set_column(column);
 				tx->update();
 
 			} break;