aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/provider.txt1
-rw-r--r--runtime/plugin/osc52.lua13
2 files changed, 6 insertions, 8 deletions
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt
index 4759b1a52e..b8182347f8 100644
--- a/runtime/doc/provider.txt
+++ b/runtime/doc/provider.txt
@@ -268,7 +268,6 @@ does as long as all of the following are true:
• |g:clipboard| is unset
• 'clipboard' is not set to "unnamed" or "unnamedplus"
• $SSH_TTY is set
- • $TMUX is unset
If any of the above conditions are not met then the OSC 52 clipboard provider
will not be used by default and Nvim will fall back to discovering a
diff --git a/runtime/plugin/osc52.lua b/runtime/plugin/osc52.lua
index 78b21863ad..374b70066f 100644
--- a/runtime/plugin/osc52.lua
+++ b/runtime/plugin/osc52.lua
@@ -2,19 +2,18 @@ local tty = vim.iter(vim.api.nvim_list_uis()):any(function(ui)
return ui.chan == 1 and ui.stdout_tty
end)
-if
- not tty
- or vim.g.clipboard ~= nil
- or vim.o.clipboard ~= ''
- or not os.getenv('SSH_TTY')
- or os.getenv('TMUX')
-then
+if not tty or vim.g.clipboard ~= nil or vim.o.clipboard ~= '' or not os.getenv('SSH_TTY') then
return
end
require('vim.termcap').query('Ms', function(cap, seq)
assert(cap == 'Ms')
+ -- Check 'clipboard' and g:clipboard again to avoid a race condition
+ if vim.o.clipboard ~= '' or vim.g.clipboard ~= nil then
+ return
+ end
+
-- If the terminal reports a sequence other than OSC 52 for the Ms capability
-- then ignore it. We only support OSC 52 (for now)
if not seq:match('^\027%]52') then