Skip to content

Commit

Permalink
[java mode] Fix indentation after class extends clause
Browse files Browse the repository at this point in the history
Closes #7049
  • Loading branch information
marijnh committed Jul 15, 2023
1 parent a0854c7 commit 69e38f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mode/clike/clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
},

indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine && isTopScope(state.context))
return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
var closing = firstChar == ctx.type;
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
Expand Down
5 changes: 5 additions & 0 deletions mode/clike/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,9 @@
"[type StringBuffer];",
"[type StringBuilder];",
"[type Void];");

MTJAVA("indent",
"[keyword public] [keyword class] [def A] [keyword extends] [variable B]",
"{",
" [variable c]()")
})();

0 comments on commit 69e38f5

Please sign in to comment.