File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
jme3-glsl-highlighter/src/com/jme3/gde/glsl/highlighter/editor Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,13 @@ public void reindent() throws BadLocationException {
5555 context .setCaretOffset (1 );
5656 final Document doc = context .document ();
5757 int indentModifier = 0 ;
58+
59+ int startOffset = context .startOffset ();
60+ int startOffsetBounded = Math .max (startOffset - 1 , 0 );
5861
5962 //Check if previous line ends with a {
60- int previousLineLength = context . startOffset () - 1 - context .lineStartOffset (context . startOffset () - 1 );
61- String previousLine = doc .getText (context .lineStartOffset (context . startOffset () - 1 ), previousLineLength );
63+ int previousLineLength = Math . max ( startOffsetBounded - context .lineStartOffset (startOffsetBounded ), 0 );
64+ String previousLine = doc .getText (context .lineStartOffset (startOffsetBounded ), previousLineLength );
6265
6366 //Hook other reasons for changes in indentation into this for loop
6467 for (int i = previousLineLength - 1 ; i >= 0 ; i --) {
@@ -69,8 +72,8 @@ public void reindent() throws BadLocationException {
6972 break ;
7073 }
7174 }
72- int previousLineIndent = context .lineIndent (context .lineStartOffset (context . startOffset () - 1 ));
73- context .modifyIndent (context . startOffset () , previousLineIndent + indentModifier );
75+ int previousLineIndent = context .lineIndent (context .lineStartOffset (startOffsetBounded ));
76+ context .modifyIndent (startOffset , previousLineIndent + indentModifier );
7477 }
7578
7679 @ Override
You can’t perform that action at this time.
0 commit comments