Jack Crowley
Jack Crowley

Reputation: 1

Sublime text 4 plugin development: memory copy problem

I am creating a plugin for sublime 4 on Ubuntu 22.04. The plugin uses pyclip (https://pypi.org/project/pyclip/) to copy text from the "clipboard" and perform certain formatting functions on the text before inserting it into the current views edit buffer.

Note: For this to work on Ubuntu you need to have xclip or xsel installed. I am using xclip

The standard use case is:

  1. The user copies a block of text from a webpage in a browser
  2. In sublime, the user runs the appropriate command that calls the plugin.
  3. The plugin calls the pyclip function to get the copied text: copied_text = pyclip.paste(text=True)
  4. The plugin performs some formatting on the text
  5. The plugin pastes the results into the current sublime window at the current cursor position.

This works great whenever the source program is a browser, another text editor, a spreadsheet, etc. HOWEVER, if the source of the text copied to the memory buffer in the cut-and-paste operation is sublime, then the function being called in the plugin to get the text, pyclip.paste(text=True), never returns and the only way to proceed is to restart sublime.

If anyone has any ideas what the issue may be it would be greatly appreciated!

I have dried this with pyperclip instead of pyclip, and with xsel instead of xclip. The problem is exactly the same. If the source program for the copy and paste operation is sublime, then sublime freezes. I have also tried this on ubuntu 20.04 and have the same results.

Upvotes: 0

Views: 42

Answers (0)

Related Questions