From 626ddcc34e8261545e5dde897c99eef4ba2ce165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Porto?= Date: Tue, 12 Nov 2024 09:23:20 -0300 Subject: [PATCH] Editor: add to watch don't create extra empty items --- Editor/AGS.Editor/GUI/WatchVariablesPanel.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs b/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs index 7aabaa36f5f..169e8150dd9 100644 --- a/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs +++ b/Editor/AGS.Editor/GUI/WatchVariablesPanel.cs @@ -427,9 +427,21 @@ private void listView1_MouseUp(object sender, MouseEventArgs e) } } + private ListViewItem AddToListView(ListViewItem item) + { + if (listView1.Items.Count > 0 && listView1.Items[listView1.Items.Count - 1].Text.Length == 0) + { + listView1.Items[listView1.Items.Count - 1].Remove(); + } + + item = listView1.Items.Add(item); + EnsureEmptyItem(); + return item; + } + public void AddVariableToWatchList(string var_name) { - ListViewItem item = listView1.Items.Add(CreateItem(var_name)); + ListViewItem item = AddToListView(CreateItem(var_name)); lock (_updateItemLock) _itemsToUpdate.Add(item); _updateItemTimer.Start();