guillermooo committed 731a9c8

Refactored function in actions to eliminate one parameter.

  • Participants
  • Parent commits 7f00ccb

Comments (0)

Files changed (2)

 import selection
 import decorators
-def compute_flags(textFlags):
+from sublime_lib.view import in_one_edit
+def compute_flags(text_flags):
     flags = 0
     flags |= re.IGNORECASE
-    flags ^= re.IGNORECASE if "c" in textFlags else 0
+    flags ^= re.IGNORECASE if "c" in text_flags else 0
     return flags
     for r in reversed(view.sel()):
         if"%s" % what, view.substr(r), compute_flags(flags)):
     for r in reversed(view.sel()):
         if not"%s" % what, view.substr(r), compute_flags(flags)):
-def replace(view, edit, what, with_this):
-    edit = view.begin_edit()
-    try:
+def replace(view, what, with_this):
+    with in_one_edit(view) as edit:
         for r in view.sel():
-            view.replace(edit, r, re.sub(what, with_this, view.substr(r)))
-    finally:
-        view.end_edit(edit)
+            view.replace(edit, r, re.sub(what, with_this, view.substr(r)))


                 if cmd[0] == "-V":
                     actions.exclude(self.view, cmd[1], cmd[2])
                 if cmd[0] == "s":
-                    actions.replace(self.view, edit, cmd[2][0], cmd[3][0])
+                    actions.replace(self.view, cmd[2][0], cmd[3][0])
         elif tokens.range:
             selection.selectSpanningLines(parseRange(tokens.range), self.view)
         elif tokens.cmd: