Move alignas alignment to context menu, fix hover state across refreshes

Replace inline alignas() editing with a proper "Align Members" submenu
in the right-click context menu. Remove alignas display from command row
and all related span/hit-test/edit machinery. Preserve hover highlight
state across document refreshes.
This commit is contained in:
MegaBlocksTM
2026-02-07 10:40:04 -07:00
committed by sysadmin
parent 02a5542f38
commit 9ec06d9658
7 changed files with 81 additions and 104 deletions

View File

@@ -1799,34 +1799,13 @@ private slots:
QCOMPARE(tree.computeStructAlignment(rootId), 1);
}
void testCommandRow2AlignasSpan() {
// Test span detection for alignas(N) in CommandRow2 text
QString text = "struct MyClass alignas(8)";
ColumnSpan span = commandRow2AlignasSpan(text);
QVERIFY(span.valid);
QVERIFY(span.start >= 0);
QVERIFY(span.end > span.start);
QString spanText = text.mid(span.start, span.end - span.start);
QCOMPARE(spanText, QString("alignas(8)"));
}
void testCommandRow2AlignasSpanNoMatch() {
// Text without alignas should return invalid span
void testCommandRow2NameSpan() {
// Name span should cover the class name
QString text = "struct MyClass";
ColumnSpan span = commandRow2AlignasSpan(text);
QVERIFY(!span.valid);
}
void testCommandRow2NameSpanStopsBeforeAlignas() {
// Name span should NOT include the alignas part
QString text = "struct MyClass alignas(4)";
ColumnSpan nameSpan = commandRow2NameSpan(text);
QVERIFY(nameSpan.valid);
QString nameText = text.mid(nameSpan.start, nameSpan.end - nameSpan.start);
QVERIFY2(!nameText.contains("alignas"),
qPrintable("Name span should not include alignas: " + nameText));
QVERIFY2(nameText.trimmed() == "MyClass",
qPrintable("Name span should be 'MyClass', got: '" + nameText.trimmed() + "'"));
}

View File

@@ -1058,20 +1058,20 @@ private slots:
m_editor->cancelInlineEdit();
}
// ── Test: alignas span detection on CommandRow2 ──
void testAlignasSpanOnCommandRow2() {
// ── Test: CommandRow2 has class type and name but no alignas ──
void testCommandRow2NoAlignas() {
m_editor->applyDocument(m_result);
// Set CommandRow2 with alignas
m_editor->setCommandRow2Text(QStringLiteral("struct _PEB64 alignas(8)"));
// Set CommandRow2 without alignas
m_editor->setCommandRow2Text(QStringLiteral("struct _PEB64"));
// Line 1 is CommandRow2
const LineMeta* lm = m_editor->metaForLine(1);
QVERIFY(lm);
QCOMPARE(lm->lineKind, LineKind::CommandRow2);
// Alignas IS allowed as inline edit (picker-based)
QVERIFY(m_editor->beginInlineEdit(EditTarget::Alignas, 1));
// RootClassName should work
QVERIFY(m_editor->beginInlineEdit(EditTarget::RootClassName, 1));
QVERIFY(m_editor->isEditing());
m_editor->cancelInlineEdit();