diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java index cd0e0c2e8d..282f111540 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/model/ObjectTableModel.java @@ -164,7 +164,7 @@ public class ObjectTableModel extends AbstractQueryTableModel { } } - public record ValueAttribute (ValueRow row, String name, Class type) + public record ValueAttribute(ValueRow row, String name, Class type) implements ValueProperty { public TraceObjectValue getEntry() { return row.getAttributeEntry(name); @@ -556,6 +556,7 @@ public class ObjectTableModel extends AbstractQueryTableModel { Set> hiddenColumns = new HashSet<>(computeAttributeColumns(byVisible.get(false))); Set> toRemove = new HashSet<>(); + boolean[] removedIndices = new boolean[getColumnCount()]; for (int i = 0; i < getColumnCount(); i++) { DynamicTableColumn exists = getColumn(i); if (!(exists instanceof AutoAttributeColumn)) { @@ -563,11 +564,31 @@ public class ObjectTableModel extends AbstractQueryTableModel { } if (!visibleColumns.remove(exists) && !hiddenColumns.remove(exists)) { toRemove.add(exists); + removedIndices[i] = true; } } + TableSortState curSortState = getTableSortState(); + TableSortStateEditor newStateEditor = new TableSortStateEditor(); + for (ColumnSortState css : curSortState.getAllSortStates()) { + int index = css.getColumnModelIndex(); + if (removedIndices[index]) { + continue; // Don't add too new + } + int precedingRemoved = 0; + for (int i = 0; i < index; i++) { + if (removedIndices[index]) { + precedingRemoved++; + } + } + newStateEditor.addSortedColumn(index - precedingRemoved, css.getSortDirection()); + } + TableSortState newSortState = newStateEditor.createTableSortState(); + + setTableSortState(TableSortState.createUnsortedSortState()); removeTableColumns(toRemove); addTableColumns(visibleColumns, true); addTableColumns(hiddenColumns, false); + setTableSortState(newSortState); } @Override