Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ public void reindent() throws BadLocationException {
context.setCaretOffset(1);
final Document doc = context.document();
int indentModifier = 0;

int startOffset = context.startOffset();
int startOffsetBounded = Math.max(startOffset - 1, 0);

//Check if previous line ends with a {
int previousLineLength = context.startOffset() - 1 - context.lineStartOffset(context.startOffset() - 1);
String previousLine = doc.getText(context.lineStartOffset(context.startOffset() - 1), previousLineLength);
int previousLineLength = Math.max(startOffsetBounded - context.lineStartOffset(startOffsetBounded), 0);
String previousLine = doc.getText(context.lineStartOffset(startOffsetBounded), previousLineLength);

//Hook other reasons for changes in indentation into this for loop
for (int i = previousLineLength - 1; i >= 0; i--) {
Expand All @@ -69,8 +72,8 @@ public void reindent() throws BadLocationException {
break;
}
}
int previousLineIndent = context.lineIndent(context.lineStartOffset(context.startOffset() - 1));
context.modifyIndent(context.startOffset(), previousLineIndent + indentModifier);
int previousLineIndent = context.lineIndent(context.lineStartOffset(startOffsetBounded));
context.modifyIndent(startOffset, previousLineIndent + indentModifier);
}

@Override
Expand Down