A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.
C++
fix(windows): preserve pending-delete red mark across selection changes
DangHuynhdb3360c4bdf9
diff --git a/windows/Gridex/DataGridView.cpp b/windows/Gridex/DataGridView.cppindex 8294da4..fdc1416 100644--- a/windows/Gridex/DataGridView.cpp+++ b/windows/Gridex/DataGridView.cpp@@ -177,6 +177,11 @@ namespace winrt::Gridex::implementation{data_ = result;selectedRow_ = -1;+ // New data set = prior row indices are meaningless; drop the+ // pending-delete visual bookkeeping. Host (WorkspacePage) also+ // discards its ChangeTracker on table switch, so the two stay+ // in sync.+ deletedRows_.clear();// EXPLAIN / EXPLAIN ANALYZE (and similar verbatim single-column// outputs) must not be truncated at 80 chars — each row is a@@ -767,6 +772,21 @@ namespace winrt::Gridex::implementationauto sp = findRowPanelByDataIndex(DataRows(), index);if (!sp) return;+ // Pending-delete visual wins over alternate-row shading: if the+ // row is in deletedRows_, paint it red + dim regardless of+ // whether it's currently selected. This prevents an earlier+ // delete's red mark from disappearing when the user clicks a+ // different row (which triggered HighlightRow on the previous+ // row and unconditionally reset its background).+ const bool isDeleted = (deletedRows_.count(index) > 0);+ if (isDeleted)+ {+ sp.Background(muxm::SolidColorBrush(+ winrt::Windows::UI::ColorHelper::FromArgb(40, 196, 43, 28)));+ sp.Opacity(0.5);+ return;+ }+if (index == selectedRow_){sp.Background(muxm::SolidColorBrush(@@ -780,6 +800,7 @@ namespace winrt::Gridex::implementation: winrt::Windows::UI::Colors::Transparent();sp.Background(muxm::SolidColorBrush(bg));}+ sp.Opacity(1.0);}// ── Mark/clear row visual states ─────────────────@@ -787,6 +808,9 @@ namespace winrt::Gridex::implementation{if (index < 0 || index >= static_cast<int>(data_.rows.size()))return;+ // Track the delete so HighlightRow / row rebuild can re-paint+ // it when selection changes or the grid re-renders.+ deletedRows_.insert(index);auto sp = findRowPanelByDataIndex(DataRows(), index);if (!sp) return;sp.Background(muxm::SolidColorBrush(@@ -796,6 +820,7 @@ namespace winrt::Gridex::implementationvoid DataGridView::ClearRowMarks(){+ deletedRows_.clear();for (uint32_t i = 0; i < DataRows().Children().Size(); i++){auto sp = DataRows().Children().GetAt(i).try_as<muxc::StackPanel>();diff --git a/windows/Gridex/DataGridView.h b/windows/Gridex/DataGridView.hindex 5cf6862..341ffcd 100644--- a/windows/Gridex/DataGridView.h+++ b/windows/Gridex/DataGridView.h@@ -4,6 +4,7 @@#include "Models/QueryResult.h"#include "Models/ColumnInfo.h"#include <functional>+#include <set>namespace winrt::Gridex::implementation{@@ -90,6 +91,15 @@ namespace winrt::Gridex::implementation// without relying on LostFocus timing.int editingRowIndex_ = -1;int editingColIndex_ = -1;++ // Row indices the user has marked for deletion (pending commit).+ // Kept here — not just in ChangeTracker — so HighlightRow /+ // BuildRowElement can re-apply the red "pending delete" visual+ // whenever a row is re-rendered (selection change, sort, page+ // switch). Previously only the last-deleted row showed red+ // because HighlightRow unconditionally reset the background on+ // selection change.+ std::set<int> deletedRows_;std::wstring sortColumn_;bool sortAscending_ = true;bool readOnly_ = false;