diff options
| author | Paulo Gomes | 2017-08-31 18:20:18 +0100 |
|---|---|---|
| committer | Paulo Gomes | 2017-09-05 00:04:08 +0100 |
| commit | af40c8698b6f13d351c3b996fb1b51db990e06e9 (patch) | |
| tree | d7803ca15b0f2ed32aa9c3bf1493fb8a7763a654 /editor/plugins/script_text_editor.cpp | |
| parent | 53e7f55a898efd1c1a3b424c3bce81c1240a9ca6 (diff) | |
| download | godot-af40c8698b6f13d351c3b996fb1b51db990e06e9.tar.gz godot-af40c8698b6f13d351c3b996fb1b51db990e06e9.tar.zst godot-af40c8698b6f13d351c3b996fb1b51db990e06e9.zip | |
Diffstat (limited to 'editor/plugins/script_text_editor.cpp')
| -rw-r--r-- | editor/plugins/script_text_editor.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 33890d890..739515934 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -953,13 +953,26 @@ void ScriptTextEditor::_edit_option(int p_op) { if (tx->get_selection_to_column() == 0) end -= 1; + // Check if all lines in the selected block are commented + bool is_commented = true; + for (int i = begin; i <= end; i++) { + if (!tx->get_line(i).begins_with("#")) { + is_commented = false; + break; + } + } for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); - if (line_text.begins_with("#")) - line_text = line_text.substr(1, line_text.length()); - else - line_text = "#" + line_text; + if (line_text.strip_edges().empty()) { + line_text = "#"; + } else { + if (is_commented) { + line_text = line_text.substr(1, line_text.length()); + } else { + line_text = "#" + line_text; + } + } tx->set_line(i, line_text); } } else { |
