I've been using Sublime Text for a few days now, and figured I would mess around with the plugin system. I decided to write a plugin that would wrap the selected strings in a html tag. However, I came across a little issue when using the code below:
The code would consistently place the closing tag 3 characters before the end of the selected region, meaning if I selected "cheese" and run the plugin, the code would generate "
ese" instead of the desired "
Now I managed to fix this by just adding three to the region.end(), but this isn't the ideal solution. Does anybody know what is causing this, or is it just a quirk of Sublime Text?
I've put the full code listing below.
def run(self, view, args):
openTag = "<p>"
closeTag = "</p>"
for region in view.sel():