mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
"Join lines" sometimes doesn't join all selected lines
This commit is contained in:
@@ -115,7 +115,7 @@ public class JoinLinesHandler extends EditorWriteActionHandler {
|
||||
int caretRestoreOffset = -1;
|
||||
// joining lines, several times if selection is multiline
|
||||
for (int i = startLine; i < endLine; i++) {
|
||||
if (i >= doc.getLineCount() - 1) break;
|
||||
if (startLine >= doc.getLineCount() - 1) break;
|
||||
|
||||
docManager.doPostponedOperationsAndUnblockDocument(doc);
|
||||
docManager.commitDocument(doc);
|
||||
|
||||
@@ -89,6 +89,7 @@ public interface IdeActions {
|
||||
@NonNls String ACTION_CUT = "$Cut";
|
||||
@NonNls String ACTION_DELETE = "$Delete";
|
||||
@NonNls String ACTION_PASTE = "$Paste";
|
||||
@NonNls String ACTION_SELECT_ALL = "$SelectAll";
|
||||
@NonNls String ACTION_CONTEXT_HELP = "ContextHelp";
|
||||
@NonNls String ACTION_EDIT_SOURCE = "EditSource";
|
||||
@NonNls String ACTION_VIEW_SOURCE = "ViewSource";
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JoinLinesAction extends TextComponentEditorAction {
|
||||
int caretRestoreOffset = -1;
|
||||
|
||||
for (int i = startLine; i < endLine; i++) {
|
||||
if (i >= doc.getLineCount() - 1) break;
|
||||
if (startLine >= doc.getLineCount() - 1) break;
|
||||
CharSequence text = doc.getCharsSequence();
|
||||
int end = doc.getLineEndOffset(startLine) + doc.getLineSeparatorLength(startLine);
|
||||
int start = end - doc.getLineSeparatorLength(startLine);
|
||||
|
||||
+7
@@ -234,4 +234,11 @@ public class EditorActionTest extends AbstractEditorTest {
|
||||
executeAction(IdeActions.ACTION_EDITOR_TOGGLE_CASE);
|
||||
checkResultByText("class C { String s = \"<selection>AB\\nCD<caret></selection>\"; }");
|
||||
}
|
||||
|
||||
public void testJoinSeveralLinesAtDocumentEnd() throws Exception {
|
||||
initText("a\nb\nc");
|
||||
executeAction(IdeActions.ACTION_SELECT_ALL);
|
||||
executeAction(IdeActions.ACTION_EDITOR_JOIN_LINES);
|
||||
checkResultByText("a b c");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user