Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot show diff in the current document #33

Closed
XaapX opened this issue Jan 9, 2013 · 7 comments
Closed

Cannot show diff in the current document #33

XaapX opened this issue Jan 9, 2013 · 7 comments

Comments

@XaapX
Copy link

XaapX commented Jan 9, 2013

I happen to work on a svn working copy with lots of new files added (A) and most of them can't show the diff in ST2, console view shows me :

Traceback (most recent call last):
File ".\Modific.py", line 391, in diff_done
File ".\Modific.py", line 314, in get_lines_to_hl
File ".\Modific.py", line 293, in get_chunks
IndexError: string index out of range

I also seems that it may been due to some property changes in the diff, the few files that work and show the diff have no property change, whereas the ones I see failing have:

Property changes on: src/xxxxx.cpp


Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
@XaapX
Copy link
Author

XaapX commented Jan 9, 2013

OK I just found what the problem is, it happens when the diff somehow has empty lines, probably because of the last part about properties.

Youi just need to replace occurences of "if line[0]" with "if line and line[0]"

@gornostal
Copy link
Owner

Thank you for the solution. I will add it to the code ASAP.

gornostal pushed a commit that referenced this issue Jan 12, 2013
@gornostal
Copy link
Owner

I could not reproduce this issue, but I made fix for it as you proposed.
Let me know if plugin works now.

@XaapX
Copy link
Author

XaapX commented Jan 12, 2013

Thanks, I'll let you know when I get back to office.
Though I remembver I had to change 2 occurences to fix it, and once more to completely get rid of stack traces.

If it does not fix, I'll send you a patch.
Thanks anyways.

@XaapX
Copy link
Author

XaapX commented Jan 14, 2013

Tested from office, I still have a backtrace and it fails.
So here is a patch :

--- Modific.py.orig  2013-01-14 11:12:13.000000000 +0100
+++ Modific.py 2013-01-14 11:14:16.000000000 +0100
@@ -312,17 +312,17 @@
         deleted = []

         for chunk in self.get_chunks():
             current = chunk['start']
             deleted_line = None
             for line in chunk['lines']:
-                if line[0] == '-':
+                if line.startswith('-'):
                     if (not deleted_line or deleted_line not in deleted):
                         deleted.append(current)
                     deleted_line = current
-                elif line[0] == '+':
+                elif line.startswith('+'):
                     if deleted_line:
                         deleted.pop()
                         deleted_line = None
                         changed.append(current)
                     elif current - 1 in changed:
                         changed.append(current)

Sorry for not bothering to fork and do a pull request, I'm at work and lacking time + git tools...

gornostal pushed a commit that referenced this issue Jan 16, 2013
@gornostal
Copy link
Owner

Thanks. I should have been using startswith instead of line[0]

@gornostal
Copy link
Owner

Please, feel free to reopen this issue, if it still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants