Sublime Forum

ST3 bug: built-in rot13 broken

#1

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:

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).

0 Likes

#2

Tools > New Plugin

Paste this (overwrite the default content):

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.

0 Likes

#3

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.

0 Likes

#4

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

0 Likes

#5

Ah, I see. Looks like unichr() became chr() in Python 3. Is there any way to pass this on to the developer(s)?

0 Likes

#6

Thanks for the report, will fix for the next build

0 Likes