Skip to content

Commit e0da91c

Browse files
authored
Fix line delimiter used by text block input assistants (eclipse-jdt#2113)
1 parent 28920b0 commit e0da91c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/AddTextBlockAction.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.jface.text.IRegion;
2727
import org.eclipse.jface.text.ITextSelection;
2828
import org.eclipse.jface.text.ITypedRegion;
29+
import org.eclipse.jface.text.TextUtilities;
2930
import org.eclipse.jface.text.source.ISourceViewer;
3031

3132
import org.eclipse.ui.IEditorInput;
@@ -155,15 +156,16 @@ private DocumentCommand getDocumentCommand(IDocument document, IJavaProject java
155156
//do nothing
156157
}
157158
}
159+
String delimiter= TextUtilities.getDefaultLineDelimiter(document);
158160
cmd.offset= selection.getOffset();
159161
cmd.length= selection.getLength();
160-
cmd.text= IndentAction.TEXT_BLOCK_STR + System.lineSeparator() + indentStr;
162+
cmd.text= IndentAction.TEXT_BLOCK_STR + delimiter + indentStr;
161163
cmd.doit= true;
162164
cmd.shiftsCaret= true;
163165
cmd.caretOffset= selection.getOffset() + selection.getLength() + cmd.text.length();
164166
cmd.text+= selection.getText();
165167
if (JavaMultiLineStringAutoIndentStrategy.isCloseStringsPreferenceSet(javaProject)) {
166-
cmd.text+= System.lineSeparator() + indentStr + IndentAction.TEXT_BLOCK_STR;
168+
cmd.text+= delimiter + indentStr + IndentAction.TEXT_BLOCK_STR;
167169
}
168170

169171
return cmd;

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaMultiLineStringAutoIndentStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private void javaMultiLineStringIndentAfterNewLine(IDocument document, DocumentC
6868
if (isCloseStringsPreferenceSet(fProject)) {
6969
command.caretOffset= command.offset + command.text.length();
7070
command.shiftsCaret= false;
71-
command.text= command.text + System.lineSeparator() + IndentAction.getTextBlockIndentationString(document, offset, command.offset, 0, fProject) + IndentAction.TEXT_BLOCK_STR;
71+
command.text= command.text + delimiter + IndentAction.getTextBlockIndentationString(document, offset, command.offset, 0, fProject) + IndentAction.TEXT_BLOCK_STR;
7272
}
7373
}
7474
} else if (command.text.length() > 1 && !isLineDelimiter && isEditorEscapeStrings()) {

0 commit comments

Comments
 (0)