|
Lines 677-689
Link Here
|
| 677 |
// compute the relative indentation difference from the second line |
677 |
// compute the relative indentation difference from the second line |
| 678 |
// (as the first might be partially selected) and use the value to |
678 |
// (as the first might be partially selected) and use the value to |
| 679 |
// indent all other lines. |
679 |
// indent all other lines. |
| 680 |
boolean isIndentDetected= false; |
|
|
| 681 |
StringBuffer addition= new StringBuffer(); |
680 |
StringBuffer addition= new StringBuffer(); |
| 682 |
int insertLength= 0; |
681 |
int insertLength= 0; |
| 683 |
int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line |
682 |
int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line |
| 684 |
int lines= temp.getNumberOfLines(); |
683 |
int lines= temp.getNumberOfLines(); |
| 685 |
int tabLength= getVisualTabLengthPreference(); |
684 |
int tabLength= getVisualTabLengthPreference(); |
| 686 |
boolean changed= false; |
|
|
| 687 |
for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents |
685 |
for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents |
| 688 |
|
686 |
|
| 689 |
IRegion r= temp.getLineInformation(l); |
687 |
IRegion r= temp.getLineInformation(l); |
|
Lines 701-723
Link Here
|
| 701 |
return; // bail out |
699 |
return; // bail out |
| 702 |
|
700 |
|
| 703 |
insertLength= subtractIndent(correct, current, addition, tabLength); |
701 |
insertLength= subtractIndent(correct, current, addition, tabLength); |
| 704 |
if (!isIndentDetected && l != first && temp.get(lineOffset, lineLength).trim().length() != 0) { |
|
|
| 705 |
isIndentDetected= true; |
| 706 |
if (insertLength == 0) { |
| 707 |
// no adjustment needed, bail out |
| 708 |
if (firstLine == 0) { |
| 709 |
// but we still need to adjust the first line |
| 710 |
command.offset= newOffset; |
| 711 |
command.length= newLength; |
| 712 |
if (changed) |
| 713 |
break; // still need to get the leading indent of the first line |
| 714 |
} |
| 715 |
return; |
| 716 |
} |
| 717 |
removeJavaStuff(temp); |
| 718 |
} else { |
| 719 |
changed= insertLength != 0; |
| 720 |
} |
| 721 |
|
702 |
|
| 722 |
// relatively indent all pasted lines |
703 |
// relatively indent all pasted lines |
| 723 |
if (insertLength > 0) |
704 |
if (insertLength > 0) |
|
Lines 727-732
Link Here
|
| 727 |
|
708 |
|
| 728 |
} |
709 |
} |
| 729 |
|
710 |
|
|
|
711 |
removeJavaStuff(temp); |
| 730 |
temp.stopRewriteSession(session); |
712 |
temp.stopRewriteSession(session); |
| 731 |
newText= temp.get(prefix.length(), temp.getLength() - prefix.length()); |
713 |
newText= temp.get(prefix.length(), temp.getLength() - prefix.length()); |
| 732 |
|
714 |
|