Skip to content

Comments

Desktop: Fixes #13574: Fix crash when opening the legacy Markdown editor#13576

Merged
laurent22 merged 2 commits intolaurent22:devfrom
personalizedrefrigerator:pr/desktop/fix-legacy-editor-crash
Nov 3, 2025
Merged

Desktop: Fixes #13574: Fix crash when opening the legacy Markdown editor#13576
laurent22 merged 2 commits intolaurent22:devfrom
personalizedrefrigerator:pr/desktop/fix-legacy-editor-crash

Conversation

@personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Oct 30, 2025

Summary

This pull request fixes a regression that caused the editor to crash when opening the legacy Markdown editor.

Fixes #13574.

Details

The regression was caused by b3bd4e0, which was mistakenly included in #13551. b3bd4e0. b3bd4e0 was intended to fix a multi-window support bug, but 1) was not fully tested and 2) was only a partial fix.

b3bd4e0 should have been pushed to a separate branch and had its own pull request with its own manual testing plan.

Testing plan

Automated testing

This pull request adds a new automated test that verifies that the legacy Markdown editor can load successfully.

Manual testing

  1. Open the Markdown editor.
  2. Search for something using global search.
  3. Click on one of the results.
  4. Verify that the results are highlighted.
  5. Repeat steps 2-4 for the legacy Markdown editor.
Screen recording
Screencast.from.2025-10-30.09-05-46.webm

const addCodeMirrorExtension = (CodeMirror: CodeMirror5Emulation) => {
CodeMirror.defineOption('joplin.search-highlight-state', null, ()=>{});
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
CodeMirror?.defineExtension('setMarkers', function(keywords: any, options: any) {
Copy link
Collaborator Author

@personalizedrefrigerator personalizedrefrigerator Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request converts setMarkers from a CodeMirror 5 legacy extension to a regular function. One of the issues that b3bd4e0 tried to address was that legacy CodeMirror 5 extensions are defined for all editor instances. As a result, clearMarkers/setMarkers would often use state associated with the wrong editor. This issue is easier to to address if the setMarkers function is a standard function that accepts an editor as input.

The legacy editor crash was caused by differences in the CodeMirror 6 compatibility layer and CodeMirror 5. In particular, the way that the current editor state was passed to the searchMarkers extension worked with the CodeMirror 6 compatibility layer, but not CodeMirror 5.

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.

Text editor not working

2 participants