|
Lines 686-722
Link Here
|
| 686 |
boolean changed= false; |
686 |
boolean changed= false; |
| 687 |
for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents |
687 |
for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents |
| 688 |
|
688 |
|
| 689 |
IRegion r= temp.getLineInformation(l); |
689 |
if (!isIndentDetected) { |
| 690 |
int lineOffset= r.getOffset(); |
690 |
IRegion r= temp.getLineInformation(l); |
| 691 |
int lineLength= r.getLength(); |
691 |
int lineOffset= r.getOffset(); |
| 692 |
|
692 |
int lineLength= r.getLength(); |
| 693 |
if (lineLength == 0) // don't modify empty lines |
693 |
|
| 694 |
continue; |
694 |
if (lineLength == 0) // don't modify empty lines |
| 695 |
|
695 |
continue; |
| 696 |
|
696 |
|
| 697 |
// indent the first pasted line |
697 |
|
| 698 |
String current= getCurrentIndent(temp, l); |
698 |
// indent the first pasted line |
| 699 |
StringBuffer correct= indenter.computeIndentation(lineOffset); |
699 |
String current= getCurrentIndent(temp, l); |
| 700 |
if (correct == null) |
700 |
StringBuffer correct= indenter.computeIndentation(lineOffset); |
| 701 |
return; // bail out |
701 |
if (correct == null) |
| 702 |
|
702 |
return; // bail out |
| 703 |
insertLength= subtractIndent(correct, current, addition, tabLength); |
703 |
|
| 704 |
if (!isIndentDetected && l != first && temp.get(lineOffset, lineLength).trim().length() != 0) { |
704 |
insertLength= subtractIndent(correct, current, addition, tabLength); |
| 705 |
isIndentDetected= true; |
705 |
if (l != first && temp.get(lineOffset, lineLength).trim().length() != 0) { |
| 706 |
if (insertLength == 0) { |
706 |
isIndentDetected= true; |
| 707 |
// no adjustment needed, bail out |
707 |
if (insertLength == 0) { |
| 708 |
if (firstLine == 0) { |
708 |
// no adjustment needed, bail out |
| 709 |
// but we still need to adjust the first line |
709 |
if (firstLine == 0) { |
| 710 |
command.offset= newOffset; |
710 |
// but we still need to adjust the first line |
| 711 |
command.length= newLength; |
711 |
command.offset= newOffset; |
| 712 |
if (changed) |
712 |
command.length= newLength; |
| 713 |
break; // still need to get the leading indent of the first line |
713 |
if (changed) |
|
|
714 |
break; // still need to get the leading indent of the first line |
| 715 |
} |
| 716 |
return; |
| 714 |
} |
717 |
} |
| 715 |
return; |
718 |
} else { |
|
|
719 |
changed= insertLength != 0; |
| 716 |
} |
720 |
} |
| 717 |
removeJavaStuff(temp); |
|
|
| 718 |
} else { |
| 719 |
changed= insertLength != 0; |
| 720 |
} |
721 |
} |
| 721 |
|
722 |
|
| 722 |
// relatively indent all pasted lines |
723 |
// relatively indent all pasted lines |
|
Lines 727-732
Link Here
|
| 727 |
|
728 |
|
| 728 |
} |
729 |
} |
| 729 |
|
730 |
|
|
|
731 |
removeJavaStuff(temp); |
| 730 |
temp.stopRewriteSession(session); |
732 |
temp.stopRewriteSession(session); |
| 731 |
newText= temp.get(prefix.length(), temp.getLength() - prefix.length()); |
733 |
newText= temp.get(prefix.length(), temp.getLength() - prefix.length()); |
| 732 |
|
734 |
|