FichteFoll / CSScheme

Create Sublime Text or Text Mate color schemes in CSS, SCSS or stylus
MIT License
43 stars 4 forks source link

Traceback caused by: edit.py #12

Closed Enteleform closed 8 years ago

Enteleform commented 8 years ago

as mentioned at [Solved] issue using “edit” objects recursively

Info:

ST Version: Stable Channel, Build 3103 OS: Windows 10 Pro (64-bit), Build 10586

Error:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 568, in run_
    return self.run(edit, **args)
TypeError: run() missing 1 required positional argument: 'name'

@ MyPlugin.py:

try:
    from .Edit import Edit as Edit
except:
    from Edit import Edit as Edit

...
...

edit = Edit(view)
edit.replace(region, text)

the above code works with my modified version of edit.py

FichteFoll commented 8 years ago

Works for me.

import sublime_plugin

class TestCommandCommand(sublime_plugin.WindowCommand):
    def run(self):
        view = self.window.active_view()
        from CSScheme.my_sublime_lib.edit import Edit

        with Edit(view) as e:
            e.replace(view.sel()[0], "replacement")

You are not supposed to use the Edit constructor in any other way than a with statement.

Your sample code is also very incomplete.

Enteleform commented 8 years ago

You are not supposed to use the Edit constructor in any other way than a with statement.

Your sample code is also very incomplete

  I figured it would be enough for you understand how I was trying to implement it, and judging by your comment above, it seems you did :smile:

 

Looks like there may have been some misunderstanding on my part.

@ the ST recursive edit issues thread; I posted this, which I assumed your response was in reference to.  

  I felt like the with implementation of the original Edit.py added unnecessary bulk to my code, so I ended up creating my own Edit.py; which can be seen in conjunction with a full implementation @ my MatchReplace proof of concept.

FichteFoll commented 8 years ago

Okay.

I do not agree with the design decisions you made for your edit.py modifications, so I will not be incorporating them into my code.

"Edits" serve the purpose to group modifications into one undo step and the way you handle it (each modification becomes its own step) defeats the purpose of that entirely. This is why we need the with statement construct or callback method: To explicitly close the edit once we're done with it, i.e. end the TextCommand.

Enteleform commented 8 years ago

Good info.  I'll probably end up reverting to the with method.

What improvements does your version of Edit.py offer over the original by linuxbochs?

FichteFoll commented 8 years ago

It should be obvious from the docstring, but iirc: