feat: configurable paste collapse thresholds (TUI + CLI)

Adds two new config keys:
- paste_collapse_threshold (default: 5) — line count threshold for
  bracketed paste collapse in both TUI and CLI
- paste_collapse_threshold_fallback (default: 0, disabled) — same for
  the fallback heuristic in terminals without bracketed paste support

TUI frontend reads these from config.get full via applyDisplay/patchUiState.
CLI reads from self.config at paste-handling time.

Closes #5626
Related: #5623
This commit is contained in:
kylekahraman 2026-05-13 12:22:35 +00:00 committed by Teknium
parent 973bb124a4
commit ab42658dfc
8 changed files with 35 additions and 7 deletions

6
cli.py
View file

@ -13351,7 +13351,8 @@ class HermesCLI:
pasted_text = _sanitize_surrogates(pasted_text)
line_count = pasted_text.count('\n')
buf = event.current_buffer
if line_count >= 5 and not buf.text.strip().startswith('/'):
threshold = self.config.get("paste_collapse_threshold", 5)
if threshold > 0 and line_count >= threshold and not buf.text.strip().startswith('/'):
_paste_counter[0] += 1
paste_dir = _hermes_home / "pastes"
paste_dir.mkdir(parents=True, exist_ok=True)
@ -13520,7 +13521,8 @@ class HermesCLI:
newlines_added = line_count - _prev_newline_count[0]
_prev_newline_count[0] = line_count
is_paste = chars_added > 1 or newlines_added >= 4
if line_count >= 5 and is_paste and not text.startswith('/'):
threshold = self.config.get("paste_collapse_threshold_fallback", 0)
if threshold > 0 and line_count >= threshold and is_paste and not text.startswith('/'):
_paste_counter[0] += 1
paste_dir = _hermes_home / "pastes"
paste_dir.mkdir(parents=True, exist_ok=True)