Skip to content

Commit

Permalink
Merge 15e6696 into 3f8dc3d
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Jul 5, 2019
2 parents 3f8dc3d + 15e6696 commit 4e7157d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions common/util/diff_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def get_indices(chunks):


def get_changes(old, new):
# if one of the inputs, either old or new is more then 10 000 characters
# we skip tring to find the words which changed. If a hunk is more than
# 10 000 charachers it is most likly a generated change.
# We skip since this calculation take a lot of time then it gets bigger.
if max(len(old), len(new)) > 10000:
return []

old_chunks = tuple(filter(lambda x: x, boundary.split(old)))
new_chunks = tuple(filter(lambda x: x, boundary.split(new)))
old_indices = get_indices(old_chunks)
Expand Down
10 changes: 7 additions & 3 deletions core/commands/inline_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ class GsInlineDiffRefreshCommand(TextCommand, GitCommand):
"""

def run(self, edit):
sublime.set_timeout_async(self.run_async, 0)

def run_async(self):
file_path = self.file_path
in_cached_mode = self.view.settings().get("git_savvy.inline_diff_view.in_cached_mode")
ignore_eol_arg = (
Expand Down Expand Up @@ -180,8 +183,10 @@ def run(self, edit):
if cursors:
row, col = self.view.rowcol(cursors[0].begin())

self.view.set_read_only(False)
self.view.replace(edit, sublime.Region(0, self.view.size()), inline_diff_contents)
self.view.run_command("gs_replace_view_text", {
"text": inline_diff_contents,
"restore_cursors": True
})

if cursors:
if (row, col) == (0, 0) and self.savvy_settings.get("inline_diff_auto_scroll", False):
Expand All @@ -197,7 +202,6 @@ def run(self, edit):
self.view.set_viewport_position((0, vp_y), False)

self.highlight_regions(replaced_lines)
self.view.set_read_only(True)

sublime.set_timeout_async(lambda: self.verify_not_conflict(), 0)

Expand Down

0 comments on commit 4e7157d

Please sign in to comment.