IDEA-86397 Delete line (Ctrl+Y) moves caret to the 1st column position

Correct 'duplicate lines' processing in case of the last line
This commit is contained in:
Denis.Zhdanov
2012-06-15 11:02:39 +04:00
parent a312c17b8e
commit 69f1247867
@@ -85,8 +85,10 @@ public class DuplicateAction extends EditorAction {
final int lineToCheck = nextLineStart.line - 1;
int newOffset = end + offset - start;
if(lineToCheck == document.getLineCount () /*empty document*/ ||
document.getLineSeparatorLength(lineToCheck) == 0) {
if(lineToCheck == document.getLineCount () /* empty document */
|| nextLineStart.line == document.getLineCount() - 1 /* last line*/
|| document.getLineSeparatorLength(lineToCheck) == 0)
{
s = "\n"+s;
newOffset++;
}