Skip to content

Add Linux support and Ctrl+A select all, need Windows testing - #225

Open
upupwrite wants to merge 23 commits into
AngryFender:masterfrom
upupwrite:master
Open

upupwrite wants to merge 23 commits into
AngryFender:masterfrom
upupwrite:master

Conversation

@upupwrite

Copy link
Copy Markdown

This PR mainly adds Linux support and Ctrl+A to select all text. I used an LLM to review most of the code, added Linux compatibility, and fixed a few small issues along the way. The comments and a lot of the more complicated code were generated by the LLM. I verified the main project source myself. The tests were also LLM-generated, and I haven't checked them line by line.

After fixing the header case issues, the project still doesn't run as expected on my machine. Basic text input doesn't even work, and it's pretty far from how it behaves on Windows. The refactor is fairly large, but GitHub Actions passes. I can't set up a proper Windows dev environment on my end, so I need someone to actually run it and verify it works on Windows, especially basic text input and Ctrl+A select all.
Thanks.

upupwrite and others added 23 commits September 5, 2026 00:13
Add CI workflow for Linux with build and test steps.
Removed xvfb installation and usage for running tests.
windowapi support for x11 and wayland
Pressing Ctrl+A followed by Backspace started a 300 ms fileSaveTimer
instead of pushing the deletion onto the undo stack immediately. If the
user pressed Ctrl+Z within that window the command had not been queued
yet, so undo either did nothing or reverted an earlier operation.

MkEdit:
- Flush any pending edit at the very top of keyPressEvent, before
  undoData.editType is overwritten, so the real edit type is still
  available to updateRawDocument / postUndoSetup.
- Treat a selection covering the whole document as a multi-block edit
  even when it sits on a single block. Previously Ctrl+A on a one-line
  document was classified as singleEdit, which stored only the current
  block in the undo snapshot and could not restore the deleted content.
- Force a fresh preUndoSetup() snapshot for multiDelete regardless of
  whether fileSaveTimer is already running, so the pre-delete raw text is
  always captured.
- Keep multiDelete out of removeAllMkData in clearMkEffects so the
  selection survives until QTextEdit::keyPressEvent runs and the whole
  selection is deleted in one step.
- Add clampDocPos() and apply it wherever a cursor position is restored
  from selectRange (applyMkEffects, postCursorPosChangedSignal,
  showSelectionAfterRedo, setPostArrowKeys, restoreTextCursor,
  clearMkEffects, insertFromMimeData) to stop the
  "QTextCursor::setPosition: Position ... out of range" warnings after
  the document shrinks.
- Sync MkEdit's selectRange to undoRedoSelectRange before applyMkEffects
  reads it on both Ctrl+Z and Ctrl+Y.

MkTextDocument:
- Add EditType::multiDelete to the enum and handle it in EditCommand's
  constructor, undo() and redo() alongside multiEdit / checkbox /
  enterPressed, so the command actually restores the full raw document.
reconstruct the func for style setting.
It is hard too test code with catchTest.
style change cannot use
TODO: global style reload in settingsdialog.cpp
have a nice day~
CatchTests/CMakeLists.txt;Enabled CatchTests in CMakeListsl.txt
Aimed to maintain the project with Linux adoption alone
Repair the CatchTests target so it actually compiles, link the missing
translation units, and complete/fix the four test files against the
current behaviour of the classes under test.

CMakeLists.txt
- Add CMAKE_AUTOUIC_SEARCH_PATHS so .ui files in the project root are
  found from the tests subdirectory; ui_mainwindow.h and
  ui_settingsdialog.h were never generated before.
- Add togglebutton.cpp and textsearchworker.cpp: views_handler.cpp
  instantiates ToggleButton and owns a TextSearchWorker, so the test
  binary failed at link time without these.
- List mainwindow.ui and settingsdialog.ui explicitly for AUTOUIC.
- Leave X11 linking commented out with a note, since windowapi.cpp is
  not part of the test target.

MkEdit_Tests.cpp
- Uncomment #include <catch2/catch.hpp>; the file was previously
  un-compilable.
- Rewrite "bold double asterisk" and "bold double underscore" to route
  text through MkTextDocument with markdown enabled. The originals used
  a bare MkEdit backed by a plain QTextDocument and compared the input
  string against itself, so they passed without exercising any markdown
  logic.
- Keep every other test body unchanged to preserve the existing
  pass/fail baseline.

mktextdocument_tests.cpp
- Add explicit includes for QChar, QString, QTextCursor and
  QTextCharFormat instead of relying on transitive includes.
- Document the two behaviours the tests rely on: setMarkdownHandle(true)
  hides every block, and cursorPosChangedHandle(&range) unhides only the
  block at range.currentBlockNo (out-of-range indices are silent no-ops).
  Comment the deliberately out-of-range currentBlockNo assignments so
  they are not "fixed" later.
- No test logic or expectation changes.

NavigationView_Tests.cpp
- Fill in the original empty "NavigationView Add file Test" placeholder.
- Add coverage for addFolder, setVaultHandler, openFileFolder,
  copyFileFolderPath, renameFile (no index), deleteFile (no selection),
  keyPressEvent (Backspace and Return), expandTimerHandler, rowClicked,
  setRowsEditable and closeEditor.
- Add a fixture that wires NavigationView to a real QFileSystemModel and
  NavigationProxyModel rooted at a QTemporaryDir for tests that need a
  valid index.
- Observe signals via QObject::connect + lambdas rather than QSignalSpy,
  because the project's signals use non-const reference parameters.
- Deliberately exclude filesystem side effects and inline-editor
  lifetime; those belong to NavigationProxyModel and to a UI-driven
  test, respectively.

RecentFilesDialog_Tests.cpp
- Replace the non-existent #include <QtTest/QTestKeyEvent> with
  <QtTest/QtTest>; the file did not compile before.
- Add missing includes for QListWidget, QListWidgetItem and
  QScopedPointer.
- Remove every delete listPtr: the dialog re-parents the supplied
  QListWidget in its constructor and owns it, so deleting it from the
  test was a use-after-free.
- Fix "adding 2 paths ... with show()" to actually insert item2; the
  original declared it but never used it, contradicting the test name.
- Send Tab with Qt::ControlModifier in all cases. A bare Tab can be
  consumed by QWidget::event()'s focus traversal before keyPressEvent()
  runs, and whether it is consumed depends on the dialog's focus state,
  which is platform-dependent because of the Qt::ToolTip window flag.
  RecentFilesDialog::keyPressEvent ignores modifiers, so the semantic
  behaviour is unchanged.
- Document the dialog's selection and insertion rules at the top of the
  file.
- No REQUIRE expectation values changed.

Notes
- No source files under test were modified; only the test tree and the
  test CMakeLists.
- Mouse-coordinate tests in MkEdit_Tests.cpp (checkbox / link clicks)
  remain sensitive to widget geometry and should be run against a real
  platform plugin, not the "offscreen" one.
Enable test CMakeLists.txt(add)
@upupwrite
upupwrite marked this pull request as draft September 24, 2026 17:28
@upupwrite
upupwrite marked this pull request as ready for review September 24, 2026 17:28
@AngryFender AngryFender self-assigned this Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants