mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-04 07:31:16 +00:00 
			
		
		
		
	Allow to undo TextEdit.set_text
This commit is contained in:
		
							parent
							
								
									201cb8d7ed
								
							
						
					
					
						commit
						3bc0445e05
					
				
					 3 changed files with 16 additions and 13 deletions
				
			
		| 
						 | 
					@ -302,7 +302,6 @@ void ScriptTextEditor::reload_text() {
 | 
				
			||||||
	int v = te->get_v_scroll();
 | 
						int v = te->get_v_scroll();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	te->set_text(script->get_source_code());
 | 
						te->set_text(script->get_source_code());
 | 
				
			||||||
	te->clear_undo_history();
 | 
					 | 
				
			||||||
	te->cursor_set_line(row);
 | 
						te->cursor_set_line(row);
 | 
				
			||||||
	te->cursor_set_column(column);
 | 
						te->cursor_set_column(column);
 | 
				
			||||||
	te->set_h_scroll(h);
 | 
						te->set_h_scroll(h);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -201,7 +201,6 @@ void TextEditor::reload_text() {
 | 
				
			||||||
	int v = te->get_v_scroll();
 | 
						int v = te->get_v_scroll();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	te->set_text(text_file->get_text());
 | 
						te->set_text(text_file->get_text());
 | 
				
			||||||
	te->clear_undo_history();
 | 
					 | 
				
			||||||
	te->cursor_set_line(row);
 | 
						te->cursor_set_line(row);
 | 
				
			||||||
	te->cursor_set_column(column);
 | 
						te->cursor_set_column(column);
 | 
				
			||||||
	te->set_h_scroll(h);
 | 
						te->set_h_scroll(h);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4196,17 +4196,22 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
 | 
				
			||||||
void TextEdit::set_text(String p_text) {
 | 
					void TextEdit::set_text(String p_text) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	setting_text = true;
 | 
						setting_text = true;
 | 
				
			||||||
 | 
						if (!undo_enabled) {
 | 
				
			||||||
		_clear();
 | 
							_clear();
 | 
				
			||||||
		_insert_text_at_cursor(p_text);
 | 
							_insert_text_at_cursor(p_text);
 | 
				
			||||||
	clear_undo_history();
 | 
						}
 | 
				
			||||||
	cursor.column = 0;
 | 
					
 | 
				
			||||||
	cursor.line = 0;
 | 
						if (undo_enabled) {
 | 
				
			||||||
	cursor.x_ofs = 0;
 | 
					 | 
				
			||||||
	cursor.line_ofs = 0;
 | 
					 | 
				
			||||||
	cursor.wrap_ofs = 0;
 | 
					 | 
				
			||||||
	cursor.last_fit_x = 0;
 | 
					 | 
				
			||||||
		cursor_set_line(0);
 | 
							cursor_set_line(0);
 | 
				
			||||||
		cursor_set_column(0);
 | 
							cursor_set_column(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							begin_complex_operation();
 | 
				
			||||||
 | 
							_remove_text(0, 0, MAX(0, get_line_count() - 1), MAX(get_line(MAX(get_line_count() - 1, 0)).size() - 1, 0));
 | 
				
			||||||
 | 
							_insert_text_at_cursor(p_text);
 | 
				
			||||||
 | 
							end_complex_operation();
 | 
				
			||||||
 | 
							selection.active = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	update();
 | 
						update();
 | 
				
			||||||
	setting_text = false;
 | 
						setting_text = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue