1515 changed, newText, newNextText = shortener.shorten() |
1515 changed, newText, newNextText = shortener.shorten() |
1516 if changed: |
1516 if changed: |
1517 if newText != text: |
1517 if newText != text: |
1518 self.__source[line] = newText |
1518 self.__source[line] = newText |
1519 if newNextText and newNextText != nextText: |
1519 if newNextText and newNextText != nextText: |
|
1520 if newNextText == " ": |
|
1521 newNextText = "" |
1520 self.__source[line + 1] = newNextText |
1522 self.__source[line + 1] = newNextText |
1521 return (1, self.trUtf8("Long lines have been shortened."), 0) |
1523 return (1, self.trUtf8("Long lines have been shortened."), 0) |
1522 else: |
1524 else: |
1523 return (0, "", 0) |
1525 return (0, "", 0) |
1524 else: |
1526 else: |
2481 if blank != -1: |
2483 if blank != -1: |
2482 first = self.__text[:blank] |
2484 first = self.__text[:blank] |
2483 second = self.__text[blank:].strip() |
2485 second = self.__text[blank:].strip() |
2484 if newNext.strip(): |
2486 if newNext.strip(): |
2485 newText = first + self.__eol |
2487 newText = first + self.__eol |
2486 newNext = self.__getIndent(newNext) + \ |
2488 if second.endswith(")"): |
2487 second + " " + newNext.lstrip() |
2489 # don't merge with next line |
|
2490 newText += self.__getIndent(newText) + second + self.__eol |
|
2491 newNext = "" |
|
2492 else: |
|
2493 newNext = self.__getIndent(newNext) + \ |
|
2494 second + " " + newNext.lstrip() |
2488 else: |
2495 else: |
2489 # empty line, add a new line |
2496 # empty line, add a new line |
2490 newText = first + self.__eol |
2497 newText = first + self.__eol |
2491 newNext = self.__getIndent(newNext) + \ |
2498 newNext = self.__getIndent(newNext) + \ |
2492 second + self.__eol + newNext.lstrip() |
2499 second + self.__eol + newNext.lstrip() |
2493 return newText, newNext |
2500 return newText, newNext |
|
2501 else: |
|
2502 return None |
2494 |
2503 |
2495 def __isProbablyInsideStringOrComment(self, line, index): |
2504 def __isProbablyInsideStringOrComment(self, line, index): |
2496 """ |
2505 """ |
2497 Private method to check, if the given string might be inside a string |
2506 Private method to check, if the given string might be inside a string |
2498 or comment. |
2507 or comment. |
2568 |
2577 |
2569 # Do end a line with a dot |
2578 # Do end a line with a dot |
2570 if first.rstrip().endswith('.'): |
2579 if first.rstrip().endswith('.'): |
2571 continue |
2580 continue |
2572 |
2581 |
2573 if tokenString in '+-*/': |
2582 if tokenString in '+-*/,': |
2574 newText = first + ' \\' + self.__eol + second |
2583 newText = first + ' \\' + self.__eol + second |
2575 else: |
2584 else: |
2576 newText = first + self.__eol + second |
2585 newText = first + self.__eol + second |
2577 |
2586 |
2578 # Only fix if syntax is okay. |
2587 # Only fix if syntax is okay. |