Просмотр исходного кода

tools: reset ConsoleView's buffer when switching project

Fixes: #142
Daniele Bartolini 3 лет назад
Родитель
Сommit
4f7e60193a
2 измененных файлов с 12 добавлено и 0 удалено
  1. 1 0
      tools/level_editor/level_editor.vala
  2. 11 0
      tools/widgets/console_view.vala

+ 1 - 0
tools/level_editor/level_editor.vala

@@ -1960,6 +1960,7 @@ public class LevelEditorApplication : Gtk.Application
 
 			this.show_panel("main_vbox", Gtk.StackTransitionType.NONE);
 			_user.add_or_touch_recent_project(source_dir, source_dir);
+			_console_view.reset();
 			restart_backend.begin(source_dir, LEVEL_NONE);
 		}
 	}

+ 11 - 0
tools/widgets/console_view.vala

@@ -155,6 +155,17 @@ public class ConsoleView : Gtk.Box
 		_console_view_valid = true;
 	}
 
+	public void reset()
+	{
+		Gtk.TextIter start;
+		Gtk.TextIter end;
+
+		Gtk.TextBuffer buffer = _text_view.buffer;
+		buffer.get_start_iter(out start);
+		buffer.get_end_iter(out end);
+		buffer.@delete(ref start, ref end);
+	}
+
 	private void on_entry_activated()
 	{
 		string text = _entry.text;