Skip to content

Disable syntax and search highlighting for very large files, based on a user-configurable size limit - #762

Open
KAMI911 wants to merge 2 commits into
linuxmint:masterfrom
KAMI911:build/perf/large-file-highlighting-limit
Open

KAMI911 wants to merge 2 commits into
linuxmint:masterfrom
KAMI911:build/perf/large-file-highlighting-limit

Conversation

@KAMI911

@KAMI911 KAMI911 commented Oct 3, 2026

Copy link
Copy Markdown

Motivation

xed had no size threshold for GtkSourceView syntax highlighting, so opening a large file made loading, scrolling, and searching noticeably slow, since the highlighting engine kept re-parsing the whole buffer on every change and every scroll.

This adds a size check when a document finishes loading: once the buffer exceeds a limit, syntax highlighting and the search "highlight all" mode are turned off automatically for that document, since they were the main cost for large files. The limit is user-configurable through Preferences > Editor > Highlighting via a new max-file-size-for-highlighting GSettings key, expressed in MB with a default of 4, where a value of 0 disables the limit entirely so highlighting is never turned off automatically. The debug log for XED_DEBUG_DOCUMENT reports the exact character count of the file and the active limit whenever this kicks in, so the behavior is easy to verify.

Also includes a small, unrelated fix for duplicate widget IDs in the preferences dialog UI file, needed for the new preference row to bind correctly.

Result

Built the branch, installed the resulting .deb, and exercised the real binary (not just the diff) with XED_DEBUG=1:

  • A synthetic 4.6 MB file (above the 4 MB / 4,000,000-character default limit) logs: File has 4600003 characters, above the 4000000-character limit (see the max-file-size-for-highlighting setting): disabling syntax highlighting for performance, and highlighting is confirmed off.
  • A 50 KB file (well under the limit) produces no such message, and highlighting stays on as before.

Kálmán „KAMI” Szalai added 2 commits September 30, 2026 18:06
… a user-configurable size limit

xed had no size threshold for GtkSourceView syntax highlighting, so opening a large file made loading, scrolling, and searching noticeably slow, since the highlighting engine kept re-parsing the whole buffer on every change and every scroll. This change adds a size check when a document finishes loading: once the buffer exceeds a limit, syntax highlighting and the search "highlight all" mode are turned off automatically for that document, since they were the main cost for large files. The limit is user-configurable through Preferences > Editor > Highlighting via a new max-file-size-for-highlighting GSettings key, expressed in MB with a default of 4, where a value of 0 disables the limit entirely so highlighting is never turned off automatically. The debug log for XED_DEBUG_DOCUMENT now reports the exact character count of the file and the active limit whenever this kicks in, so the behavior is easy to verify.
The new highlighting-limit box and label reused the ids box6 and label2, which already existed elsewhere in the same GtkBuilder file. Duplicate ids in one interface file confuse GtkBuilder and left the whole preferences dialog blank when opened. Renamed the new widgets to box31 and label30, which are not used anywhere else in the file.
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.

1 participant