mirror of
https://github.com/neovim/neovim.git
synced 2026-01-05 02:47:28 +10:00
fix(vim.net): filetype detection, mark unmodified #36297
Problem: When running ":edit <url>", filetype detection is not triggered. Solution: Run the autocmds in the filetypedetect group after loading the content. Problem: After fetching remote content from a URL and adding it to the buffer, the buffer is marked as modified. This is inconsistent with the original netrw behavior, and it causes problems with `:e` to refresh or `:q` as it prompts for saving the file even if the user hasn't touched the content at all. Solution: Mark the buffer as unmodified right after adding the remote content to the buffer.
This commit is contained in:
committed by
GitHub
parent
e0308dc147
commit
69b286c3bf
@@ -28,6 +28,8 @@ local function on_remote_read(args)
|
||||
|
||||
local lines = vim.split(content.body, '\n', { plain = true })
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines)
|
||||
vim.api.nvim_exec_autocmds('BufRead', { group = 'filetypedetect', buffer = bufnr })
|
||||
vim.bo[bufnr].modified = false
|
||||
|
||||
vim.fn.winrestview(view)
|
||||
vim.api.nvim_echo({ { 'Loaded ' .. url, 'Normal' } }, true, {})
|
||||
|
||||
Reference in New Issue
Block a user