Skip to content

Large-file threshold was defined in two places (1 MB vs 100 MB), causing inconsistent handlingΒ #2540

Closed

Description

@sinelaw

Summary

The "large file" threshold β€” which decides whether a file loads eagerly (full line index, LSP, exact scrollbar) or lazily (chunked, no line index β†’ byte-offset gutter/status, LSP skipped) β€” was defined by two competing constants with different values, and several sites didn't honor the user setting. As a result the effective threshold depended on which code path you hit.

Symptom

Opening a file between the two thresholds β€” e.g. jumping to a definition inside slangd's dumped core builtin module (~2.1 MB) β€” put the buffer into large-file mode: the gutter and status bar showed byte offsets instead of line numbers ("Byte 126437" rather than "Ln 4262, Col 25"), and LSP was disabled, even though 2 MB is a perfectly reasonable "small" file.

Root cause

Definition Value Role
config::LARGE_FILE_THRESHOLD_BYTES 1 MB config default β€” but also hardcoded directly in some production sites
buffer::DEFAULT_LARGE_FILE_THRESHOLD 100 MB second, divergent constant: the load-path == 0 fallback and the (dead) check_large_file_encoding

Plus:

  • check_large_file_encoding was a pub fn with no production caller (only a test) that carried the 100 MB value; the real encoding-confirmation flow is driven by load_large_file_internal.
  • composite_buffer_actions passed the constant instead of the config value.
  • wasm had its own third 100 MB copy.
  • highlighter::MAX_PARSE_BYTES (a viewport parse budget β€” a distinct concern) borrowed the file-threshold constant.

So editor.large_file_threshold_bytes did not actually control the whole chain, and the default was an aggressively low 1 MB.

Fix

Consolidated to a single source of truth: editor.large_file_threshold_bytes, whose only constant is its default, raised to 10 MB. Removed the 100 MB duplicate, the == 0 fallback, and the dead check_large_file_encoding; routed the production bypass through the config value; gave the highlighter its own budget constant; regenerated plugins/config-schema.json.

Verified: go-to-definition into the 2.1 MB core builtin now opens with line numbers ("Ln 4262, Col 25").

Fixed on branch claude/slangd-lsp-testing-372g8o (commits 6e24fab, 57338e2).

Follow-up

The large_file_threshold parameter is still threaded through in-memory constructors that ignore it β€” tracked separately as tech debt.

Activity

  1. added 2 commits that reference this issue on Jul 1, 2026
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions