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

fix: calculate blob line without strdisplaywidth #29

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

aileot
Copy link
Contributor

@aileot aileot commented Nov 2, 2024

Sorry, vim.fn.getline() did not solve the issue #23.
I checked out at a wrong path due to lazy.nvim dev option :(

Try opening a luac file under ~/.cache/nvim/luac/.

This is a workaround for the error "E976: using Blob as a String" on
strdisplaywidth.

Lines containing control characters are expected to be only composed of
ASCII.
@Bekaboo
Copy link
Owner

Bekaboo commented Nov 4, 2024

Cannot reproduce:

https://asciinema.org/a/z7s9MvvQtz4LGhV8JimntfJij

minimal.lua:

local tmp = vim.env.TMPDIR or vim.env.TEMPDIR or vim.env.TMP or vim.env.TEMP or "/tmp"
local data = tmp .. "/" .. (vim.env.NVIM_APPNAME or "nvim")
local packages_root = data .. "/site"
local cloned_root = packages_root .. "/pack/packages/start"
local cloned_path = cloned_root .. "/deadcolumn.nvim"
local url = "https://github.com/Bekaboo/deadcolumn.nvim.git"

vim.opt.rtp:prepend(packages_root)
if not vim.loop.fs_stat(cloned_path) then
	vim.fn.mkdir(cloned_root, "p")
	vim.fn.system({ "git", "clone", url, cloned_path })
end
vim.opt.rtp:prepend(cloned_path)

require("deadcolumn").setup()

@aileot
Copy link
Contributor Author

aileot commented Nov 4, 2024

It turns out that the issue only happens with vim.tbl_map().
https://asciinema.org/a/py7SGUREbB0tSds34hJXLwZGJ

To reproduce the issue, the minimal.lua requires some changes:

local tmp = vim.env.TMPDIR or vim.env.TEMPDIR or vim.env.TMP or vim.env.TEMP or "/tmp"
local data = tmp .. "/" .. (vim.env.NVIM_APPNAME or "nvim")
local packages_root = data .. "/site"
local cloned_root = packages_root .. "/pack/packages/start"
local cloned_path = cloned_root .. "/deadcolumn.nvim"
local url = "https://github.com/Bekaboo/deadcolumn.nvim.git"

vim.opt.rtp:prepend(packages_root)
if not vim.loop.fs_stat(cloned_path) then
  vim.fn.mkdir(cloned_root, "p")
  vim.fn.system({ "git", "clone", url, cloned_path })
end
vim.opt.rtp:prepend(cloned_path)

-- Just change here.
-- require("deadcolumn").setup()
require("deadcolumn").setup({ scope = "buffer" })
vim.o.colorcolumn = "1"

@Bekaboo
Copy link
Owner

Bekaboo commented Nov 4, 2024

Ahh good catch!

It turns out that the issue only happens with vim.tbl_map()

I forget to use vim.fn.line() instead of the api function to get lines in other scope configs. vim.tbl_map() is not the culprit.

@Bekaboo Bekaboo merged commit 897c905 into Bekaboo:master Nov 4, 2024
3 checks passed
@aileot aileot deleted the fix-blob-lines branch November 4, 2024 20:57
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.

2 participants