Skip to content

folds are gone after diff #265

@mosheavni

Description

@mosheavni

Neovim version (nvim -v | head -n1)

NVIM v0.11.0-dev-1410+gc51bf5a6b2

Operating system/version

macOS 15.2

How to reproduce the issue

cat mini.lua

vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
local temp_dir = vim.uv.os_getenv 'TEMP' or '/tmp'
local package_root = vim.fs.joinpath(temp_dir, 'nvim', 'site', 'lazy')
local lazypath = vim.fs.joinpath(temp_dir, 'nvim', 'site') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim
    .system({
      'git',
      'clone',
      '--filter=blob:none',
      '--single-branch',
      'https://github.com/folke/lazy.nvim.git',
      lazypath,
    }, { text = true })
    :wait()
end
vim.opt.runtimepath:prepend(lazypath)

_G.load_config = function()
  vim.lsp.set_log_level 'trace'
  require('vim.lsp.log').set_format_func(vim.inspect)
  local nvim_lsp = require 'lspconfig'

  -- Add the server that troubles you here
  local name = 'lua_ls'
  local capabilities = vim.lsp.protocol.make_client_capabilities()
  capabilities.textDocument.foldingRange = {
    dynamicRegistration = false,
    lineFoldingOnly = true,
  }

  nvim_lsp[name].setup { capabilities = capabilities }
  require('ufo').setup { open_fold_hl_timeout = 0 }

  print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end

require('lazy').setup({
  'neovim/nvim-lspconfig',
  {
    'kevinhwang91/nvim-ufo',
    dependencies = { 'kevinhwang91/promise-async' },
    init = function()
      vim.o.foldcolumn = '1'
      vim.o.foldlevel = 99
      vim.o.foldlevelstart = 99
      vim.o.foldenable = true
    end,
  },
}, {
  root = package_root,
})
_G.load_config()

nvim -nu mini.lua

  1. edit any lua file (even the mini.lua one): :e mini.lua
  2. make sure there are folds
  3. run :diffthis
  4. run :diffoff
  5. no folds

Expected behavior

folds should reappear after diff is turned off

Actual behavior

folds are gone after diff

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions