fix(dim): fixed the issue of dim's scope variable being nil and outputting… (#1938)

## Description

During my use of dim, I found that an empty document can cause Snacks to
output error messages, resulting in an instant freeze when opening an
empty file

## Related Issue(s)

- Fixes #1810 

## Screenshots
before change

![before-fix-dim](https://github.com/user-attachments/assets/203791d7-629a-4650-9c87-a04fb81bad3d)


after change

![after-fix-dim](https://github.com/user-attachments/assets/44097f7d-2229-4407-8868-388e758774b5)
This commit is contained in:
Liu Zehao 2025-10-15 00:29:08 +08:00 committed by GitHub
parent 839022302b
commit 943a3c7d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,7 +108,9 @@ function M.enable(opts)
buf = buf,
}
end
if scope == nil then
return
end
Snacks.animate(scopes_anim[win].from, scope.from, function(v)
if not scopes_anim[win] or not vim.api.nvim_win_is_valid(win) then
return