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

Issues when OSC 52 is in use #636

Open
2 tasks done
ldelossa opened this issue Dec 18, 2024 · 5 comments
Open
2 tasks done

Issues when OSC 52 is in use #636

ldelossa opened this issue Dec 18, 2024 · 5 comments
Labels
backlog Likely not getting to it anytime soon bug Something isn't working

Comments

@ldelossa
Copy link

ldelossa commented Dec 18, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

Remote development is more popular than ever.

Often times the simplest way to get copy and paste working on a remote machine it ouse OSC 52 term codes.

Blink.cmp seems to be doing something behind the scenes which causes unnecessary OSC 52 termcodes. This could be spurious copy or pastes to the system buffer.

I'm noticing when I install Blink.cmp, as soon as I copy something into the system register, changing VIM to INSERT mode causes OSC 52 to wait for a response from the terminal.

image

As soon as I remove Blink.cmp this is no longer an issue.

Relevant configuration

No response

neovim version

v0.11.0-dev+1369-gb03e790cd (nightly)

blink.cmp version: branch, tag, or commit

v0.7.4

@ldelossa ldelossa added the bug Something isn't working label Dec 18, 2024
@ldelossa
Copy link
Author

ldelossa commented Dec 18, 2024

Issue seems to be with this function:

local function get_selected_text()
  if vim.fn.visualmode() == 'V' then return vim.fn.trim(vim.fn.getreg(vim.v.register, true), '\n', 2) end
  return ''
end

I can reproduce with OSC 52 on:

	vim.g.clipboard = {
		name = 'OSC 52',
		copy = {
			['+'] = require('vim.ui.clipboard.osc52').copy('+'),
			['*'] = require('vim.ui.clipboard.osc52').copy('*'),
		},
		paste = {
			['+'] = require('vim.ui.clipboard.osc52').paste('+'),
			['*'] = require('vim.ui.clipboard.osc52').paste('*'),
		},
	}

Now, highlight a line and yank it, then enter INSERT then NORMAL and back to INSERT. At that last enter back into INSERT you'll get stuck on OSC waiting for the terminal.

@Saghen
Copy link
Owner

Saghen commented Dec 18, 2024

Did you mean v0.7.4 for your blink.cmp version? This one seems pretty niche so I'll put it in the backlog for now, but if you manage to debug it, I can definitely take another look!

@Saghen Saghen added the backlog Likely not getting to it anytime soon label Dec 18, 2024
@ldelossa
Copy link
Author

ldelossa commented Dec 18, 2024

@Saghen

I can probably debug, but I would like more info about what get_selected_text() and its usage is trying to accomplish?
I'm reading this as

"On insert, if you've ever been in a visual mode since Vim started, yank the contents of the last used register, and trim it, etc..."

Is that correct, and if so whats the main use of this?

@Saghen
Copy link
Owner

Saghen commented Dec 18, 2024

It's used by the snippets engine very rarely, for $TM_SELECTED_TEXT based on https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables

@ldelossa
Copy link
Author

"Currently selected text" could also mean just the "currently highlighted text" in visual mode, no? Do we necessarily need to get a register? The text in a register could have been selected weeks ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Likely not getting to it anytime soon bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants