Skip to content

Commit

Permalink
Moving text blocks destroys the contents indentation
Browse files Browse the repository at this point in the history
- add check for multi-line string partition and don't indent line
  in IndentUtil.indentLine() method if within that partition
- fixes #21
  • Loading branch information
jjohnstn committed Apr 29, 2022
1 parent 95fc3a4 commit 8eb048c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others.
* Copyright (c) 2005, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -411,6 +411,10 @@ private static boolean indentLine(IDocument document, int line, JavaIndenter ind
// as opposed to commented out code, which should keep its slashes at column 0
if (length > 0) {
ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, end, false);
if (IJavaPartitions.JAVA_MULTI_LINE_STRING.equals(partition.getType())) {
// don't play with indentation of a Text Block
return false;
}
if (partition.getOffset() == end && IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(partition.getType())) {
commentLines[lineIndex]= true;
}
Expand Down

0 comments on commit 8eb048c

Please sign in to comment.