mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-04 07:31:16 +00:00 
			
		
		
		
	Merge pull request #29262 from DarknessCatt/issue-27476
Automatically add new line to scripts
This commit is contained in:
		
						commit
						7842f4ca5c
					
				
					 10 changed files with 46 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -804,6 +804,24 @@ void CodeTextEditor::trim_trailing_whitespace() {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CodeTextEditor::insert_final_newline() {
 | 
			
		||||
	int final_line = text_editor->get_line_count() - 1;
 | 
			
		||||
 | 
			
		||||
	String line = text_editor->get_line(final_line);
 | 
			
		||||
 | 
			
		||||
	//length 0 means it's already an empty line,
 | 
			
		||||
	//no need to add a newline
 | 
			
		||||
	if (line.length() > 0 && !line.ends_with("\n")) {
 | 
			
		||||
		text_editor->begin_complex_operation();
 | 
			
		||||
 | 
			
		||||
		line += "\n";
 | 
			
		||||
		text_editor->set_line(final_line, line);
 | 
			
		||||
 | 
			
		||||
		text_editor->end_complex_operation();
 | 
			
		||||
		text_editor->update();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CodeTextEditor::convert_indent_to_spaces() {
 | 
			
		||||
	int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
 | 
			
		||||
	String indent = "";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue