From b0395c2882dbc7412edad9888794de131ad6e365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=8A=E5=96=AC?= Date: Sun, 19 Feb 2023 18:08:46 +0800 Subject: [PATCH] fix: avoid eval "= directly in builtin registers picker (#2347) When "= contains expression not ought to be run in current context, the `getreg('=')` raises error. For example `:put =foo` (where `foo` is undefined) then open registers picker it fails. Also #2228. Now specify second arg to `getreg` to get register expr (instead of "evaluated" result) as content, like what `:registers` command displays. This has behavior change, if user still want to see/paste the evaluated result, a customized action will be needed. --- lua/telescope/make_entry.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 35011aa..272524b 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -820,7 +820,7 @@ function make_entry.gen_from_registers(opts) end return function(entry) - local contents = vim.fn.getreg(entry) + local contents = vim.fn.getreg(entry, 1) return make_entry.set_default_entry_mt({ value = entry, ordinal = string.format("%s %s", entry, contents),