I’m trying to understand how view.replace
method works but I haven’t been able to figure it yet…
Docs says:
replace(edit, region, string) None Replaces the contents of the region with the given string.
not much relevant info… and the method in sublime.py
is just a simple wrapper:
def replace(self, edit, r, text):
if edit.edit_token == 0:
raise ValueError("Edit objects may not be used after the TextCommand's run method has returned")
sublime_api.view_replace(self.view_id, edit.edit_token, r, text)
So I’ve tried to analize the behaviour with the next dummy TextCommand
:
class FooCommand(sublime_plugin.TextCommand):
def run(self, edit, block=False):
self.view.replace(edit, sublime.Region(0,10), "abcde")
Here’s the tests I’ve used to understand the behaviour:
But this is still eluding me…
@jps or @wbond Hey guys, sorry to ping… I won’t ask for sublime_api.view_replace
source but would you mind to explain how the algorithm works internally?
Thanks in advance!