n1k0 / SublimeHighlight

A humble SublimeText package for exporting highlighted code as RTF or HTML

Home Page:https://github.com/n1k0/SublimeHighlight

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy RTF to clipboard fails

cgarrard opened this issue · comments

I'm using S3 on x64 Win7. For some reason certain blocks of text fail to copy to the clipboard as RTF. View or convert to RTF both work, as does HTML. If I select fewer or more lines of text, then sometimes it will work. But selecting the same text again (even much later) still fails. I've tried to figure out if there is a pattern with beginning or ending characters in the selection, but if there is a pattern, I haven't found it.

Here's the traceback:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 543, in run_
    return self.run(edit, **args)
  File "C:\Users\chrisg\AppData\Roaming\Sublime Text 3\Packages\Highlight\SublimeHighlight.py", line 143, in run
    winclip.Paste(pygmented, output_type, plaintext)
  File "C:\Users\chrisg\AppData\Roaming\Sublime Text 3\Packages\Highlight\HighlightLib\winclip\__init__.py", line 47, in Paste
    Put(data, CF_RTF)
  File "C:\Users\chrisg\AppData\Roaming\Sublime Text 3\Packages\Highlight\HighlightLib\winclip\__init__.py", line 68, in Put
    raise Exception('Failed to lock: %r' % code)
Exception: Failed to lock: 6

I get something similar:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 543, in run_
    return self.run(edit, **args)
  File "C:\Users\Eric\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\SublimeHighlight.py", line 143, in run
    winclip.Paste(pygmented, output_type, plaintext)
  File "C:\Users\Eric\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\HighlightLib\winclip\__init__.py", line 53, in Paste
    Put(unicodetext, CF_UNICODETEXT)
  File "C:\Users\Eric\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\HighlightLib\winclip\__init__.py", line 68, in Put
    raise Exception('Failed to lock: %r' % code)
Exception: Failed to lock: 6

Similar error:

Traceback (most recent call last):
  File "F:\Program Files\Sublime Text 3\sublime_plugin.py", line 543, in run_
    return self.run(edit, **args)
  File "C:\Users\lenovo\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\SublimeHighlight.py", line 143, in run
    winclip.Paste(pygmented, output_type, plaintext)
  File "C:\Users\lenovo\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\HighlightLib\winclip\__init__.py", line 52, in Paste
    Put(plaintext, CF_TEXT)
  File "C:\Users\lenovo\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\HighlightLib\winclip\__init__.py", line 68, in Put
    raise Exception('Failed to lock: %r' % code)
Exception: Failed to lock: 6

same here....

Also getting the same error as everyone else. Any updates on this?

I got the same error.
Then I check the HighlightLib/winclip/init.py, at line 52 and 53, it's
Put(plaintext, CF_TEXT)
Put(unicodetext, CF_UNICODETEXT)

I think it should be the error when it try to put twice, I just comment the first Put line,
it works!

I have fixed my issues as well by doing the following (Windows):

  1. Open C:\Users\YourName\AppData\Roaming\Sublime Text 3\Packages\SublimeHighlight\HighlightLib\winclip__init__.py
  2. Comment out lines 52 and 53.

    Put(plaintext, CF_TEXT)

    Put(unicodetext, CF_UNICODETEXT)

  3. Save, and restart sublime.

After I did this, copying as RTF or HTML both work, and I was able to paste into editors like Microsoft Word and Evernote just fine.

Nice. Can someone submit a PR for this?