Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple preview hooks trigger on large file #1252

Closed
Akeboshiwind opened this issue Sep 17, 2021 · 1 comment · Fixed by #1253
Closed

Multiple preview hooks trigger on large file #1252

Akeboshiwind opened this issue Sep 17, 2021 · 1 comment · Fixed by #1253
Labels
bug Something isn't working

Comments

@Akeboshiwind
Copy link

Akeboshiwind commented Sep 17, 2021

Description

This is related to the new preview config that's been added.

If you have a filesize_hook set it will trigger and generate you the buffer you want, but it will then be overridden with the output of timeout_hook or it's default.

For example:

That gif has been slowed down by github for reasons unknown but it makes the issue easier to see.

Neovim version

NVIM v0.6.0-dev+43-g02bf251bb
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

macOS 10.15.7

checkhealth telescope

health#telescope#check
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 12.1.1
  - WARNING: fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

## ===== Installed extensions =====

## Telescope Extension: `fzf`
  - INFO: No healthcheck provided

Steps to reproduce

  1. yes "This is just a sample line appended to create a big file." | head -n 1000000 > out.txt
  2. nvim -nu minimal.lua
  3. :Telescope find_files
  4. Navigate to file in browser and observe preview changes multiple times

Expected behavior

The first one to resolve (the filesize limit) should be shown.
Otherwise to use the filesize_hook you have to disable timeouts

Actual behavior

The filesize_hook fires, then the timeout_hook (or it's default) fires

Minimal config

---@diagnostic disable: unused-local
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()

  -- ===== vv Changes in config here vv =====
  require('telescope').setup({
      defaults = {
          preview = {
              timeout_hook = function(filepath, bufnr, opts)
                  local cmd = {"echo", "timeout"}
                  require('telescope.previewers.utils').job_maker(cmd, bufnr, opts)
              end,
              filesize_hook = function(filepath, bufnr, opts)
                  local cmd = {"echo", "filesize"}
                  require('telescope.previewers.utils').job_maker(cmd, bufnr, opts)
              end
          }
      }
  })
  -- ===== ^^ Changes in config here ^^ =====

  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
@Akeboshiwind Akeboshiwind added the bug Something isn't working label Sep 17, 2021
@Akeboshiwind
Copy link
Author

Side note: I had to edit the issue because the checkhealth wasn't surrounded in a code block FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant