mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-196178 Join Lines on selected text also joins not selected text
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
class Foo {
|
||||
void test() {
|
||||
int a = 2;
|
||||
int b = 2;
|
||||
|
||||
<selection>if (a == b){
|
||||
if (a > b){
|
||||
System.out.println();
|
||||
}
|
||||
}</selection>
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
void test() {
|
||||
int a = 2;
|
||||
int b = 2;
|
||||
|
||||
if (a == b && a > b) System.out.println();
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class JoinLinesTest extends LightCodeInsightTestCase {
|
||||
public void testIfChainPolyadic() { doTest(); }
|
||||
public void testIfChainNoBraces() { doTest(); }
|
||||
public void testIfChainElse() { doTest(); }
|
||||
public void testIfChainSelection() { doTest(); }
|
||||
|
||||
public void testSCR3493() {
|
||||
CommonCodeStyleSettings settings = getJavaSettings();
|
||||
|
||||
@@ -88,11 +88,16 @@ public class JoinLinesHandler extends EditorActionHandler {
|
||||
Ref<Integer> caretRestoreOffset = new Ref<>(-1);
|
||||
CodeEditUtil.setNodeReformatStrategy(node -> node.getTextRange().getStartOffset() >= startReformatOffset);
|
||||
try {
|
||||
for (int count = 0; count < lineCount; count++) {
|
||||
int count = 0;
|
||||
while (count < lineCount) {
|
||||
indicator.checkCanceled();
|
||||
indicator.setFraction(((double)count) / lineCount);
|
||||
int beforeLines = doc.getLineCount();
|
||||
ProgressManager.getInstance().executeNonCancelableSection(
|
||||
() -> doJoinTwoLines(doc, project, docManager, psiFile, line, caretRestoreOffset));
|
||||
int afterLines = doc.getLineCount();
|
||||
// Single Join two lines procedure could join more than two (e.g. if it removes braces)
|
||||
count += Math.max(beforeLines - afterLines, 1);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user