Skip to content

Scroll position resets to end of document on external file change #4151

Closed

Description

@Wordbe

Description

When a file is modified by an external editor (e.g. VS Code, terminal), MarkText reloads the content but the scroll position jumps to the end of the document and the cursor moves to the last line. This is disruptive when working with long documents.

  • Can you reproduce the issue?

Steps to reproduce

  1. Open a long markdown file (200+ headings) in MarkText
  2. Scroll to the middle of the document (e.g. around section 100)
  3. Without closing MarkText, modify the file externally:
    echo "# Added externally" >> yourfile.md
  4. Switch back to MarkText

Expected behavior:
The scroll position stays at the same location (section 100 area).

Actual behavior:
The scroll position jumps to the end of the document and the cursor moves to the last line. This happens in both WYSIWYG mode and source code mode.

Related issues

Root cause

In src/renderer/store/editor.js, the LISTEN_FOR_FILE_CHANGE mutation emits file-changed with renderCursor: true, which triggers scrollToCursor() after reloading content. Additionally, importMarkdown.js defaults the cursor to getLastBlock() (end of document) when no cursor info is available, causing the scroll to jump to the bottom.

Versions

  • MarkText version: 0.17.1
  • Operating system: macOS (Darwin 25.3.0)

Activity

  1. added
    🐛 bug
    🪲 pri/major
    on May 13, 2026
  2. added a commit that references this issue on May 16, 2026
    1cce719
  3. added a commit that references this issue on May 18, 2026
    818a2fc
  4. added a commit that references this issue on Jun 21, 2026
    900c120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 pri/major🐛 bug🔭 area/editor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions