Skip to content

fix(previewer): improve file_maker line splitting and timeouts#3261

Merged
Conni2461 merged 1 commit into
nvim-telescope:masterfrom
jamestrew:file-maker-split
May 4, 2026
Merged

fix(previewer): improve file_maker line splitting and timeouts#3261
Conni2461 merged 1 commit into
nvim-telescope:masterfrom
jamestrew:file-maker-split

Conversation

@jamestrew
Copy link
Copy Markdown
Contributor

@jamestrew jamestrew commented Aug 18, 2024

Previous method of splitting files into lines and incorporating a timer is sub-optimal in two ways

By avoiding using vim.gsplit, we can avoid some overheads it needs to account for patterns and options, and we can check for timeouts more incrementally (every 200 bytes) to avoid getting caught up in huge singular lines.

Based on quick and dirty benchmarks against large-ish files in the issue above, I'm seeing about a 4-5x speed increase.

@clason
Copy link
Copy Markdown
Contributor

clason commented Apr 11, 2026

@jamestrew rebase?

@jamestrew jamestrew force-pushed the file-maker-split branch from 18a8b8d to ec72152 Compare May 1, 2026 20:36
@Conni2461
Copy link
Copy Markdown
Member

thanks :)

@Conni2461 Conni2461 merged commit be6a84e into nvim-telescope:master May 4, 2026
9 checks passed
@clason
Copy link
Copy Markdown
Contributor

clason commented May 4, 2026

Sorry for not testing this earlier, but this triggers an error with file previews (on Nvim nightly):

vim.schedule callback: ...m/lazy/telescope.nvim/lua/telescope/previewers/utils.lua:267: attempt to compare boolean with number
stack traceback:
        ...m/lazy/telescope.nvim/lua/telescope/previewers/utils.lua:267: in function 'timed_split_lines'
        ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:189: in function 'fn'
        [string "vim/_core/editor"]:404: in function <[string "vim/_core/editor"]:403>

This is with opts.preview.timeout = false, which is a valid option to not time out.

Workaround: Set opts.preview.timeout = math.huge to disable the timeout.

@Conni2461
Copy link
Copy Markdown
Member

does this help? #3662

@clason
Copy link
Copy Markdown
Contributor

clason commented May 4, 2026

Yes! (I would also have considered adapting the documentation, but this is less breaking.)

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.

3 participants