Closed XaapX closed 11 years ago
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]"
Thank you for the solution. I will add it to the code ASAP.
I could not reproduce this issue, but I made fix for it as you proposed. Let me know if plugin works now.
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.
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...
Thanks. I should have been using startswith
instead of line[0]
Please, feel free to reopen this issue, if it still occurs.
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