Home Download Buy Blog Forum Support

ST3 bug: built-in rot13 broken

ST3 bug: built-in rot13 broken

Postby hryx on Sat Mar 02, 2013 10:20 pm

ROT-13 seems to be broken in ST3 beta. I'm using build 3012 on OS X 10.8.2.

Steps to reproduce:
  • Select text
  • Command palette > Rot13 selection
  • Sit back and watch nothing happen

Console output:

Code: Select all
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 418, in run_
    return self.run(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package/transform.py", line 7, in run
  File "/Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package/transform.py", line 14, in transform
  File "/Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package/transform.py", line 38, in <lambda>
  File "/Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package/transform.py", line 38, in <listcomp>
  File "/Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package/transform.py", line 34, in rot13
NameError: global name 'unichr' is not defined


Same steps work just fine in ST2 (no console output).
hryx
 
Posts: 4
Joined: Sat Mar 02, 2013 9:55 pm

Re: ST3 bug: built-in rot13 broken

Postby weslly on Sat Mar 02, 2013 10:38 pm

Tools > New Plugin

Paste this (overwrite the default content):
Code: Select all
import sublime, sublime_plugin
import codecs

class Rot13Command(sublime_plugin.TextCommand):

    def run(self, edit):
        for region in self.view.sel():
            if not region.empty():
                # Get the selected text
                s = self.view.substr(region)
                # Transform it via rot13

                s = codecs.encode(s, 'rot_13')
                # Replace the selection with transformed text
                self.view.replace(edit, region, s)



Save in the "User" folder inside your packages directory.
weslly
 
Posts: 203
Joined: Sun Aug 28, 2011 3:57 am
Location: Brazil

Re: ST3 bug: built-in rot13 broken

Postby hryx on Sat Mar 02, 2013 11:03 pm

I will check out the fix, but this was more of a bug report than a help request (and I don't see any other obvious appropriate place to report bugs).

Am I mistaken? Is rot13 not a built-in plugin, showing here to be broken? I'm on a fresh install of ST3 and I've added no plugins. Do user plugins from ST2 get copied to the ST3 directory automatically upon upgrade?

Edit: I just did a "truly" clean install on a Linux VM with no previous versions (no ST2 or ST3). Same results as above. I would call this unintended behavior.
hryx
 
Posts: 4
Joined: Sat Mar 02, 2013 9:55 pm

Re: ST3 bug: built-in rot13 broken

Postby weslly on Sat Mar 02, 2013 11:33 pm

It's a bug indeed. Seems like the code for this command wasn't ported to Python 3 yet.
weslly
 
Posts: 203
Joined: Sun Aug 28, 2011 3:57 am
Location: Brazil

Re: ST3 bug: built-in rot13 broken

Postby hryx on Sun Mar 03, 2013 2:01 am

weslly wrote:It's a bug indeed. Seems like the code for this command wasn't ported to Python 3 yet.

Ah, I see. Looks like unichr() became chr() in Python 3. Is there any way to pass this on to the developer(s)?
hryx
 
Posts: 4
Joined: Sat Mar 02, 2013 9:55 pm

Re: ST3 bug: built-in rot13 broken

Postby jps on Sun Mar 03, 2013 11:12 pm

Thanks for the report, will fix for the next build
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 18 guests