Groovy-Emacs-Modes / groovy-emacs-modes

A groovy major mode, grails minor mode, and a groovy inferior mode.
84 stars 39 forks source link

Incorrect indentation occurs when slash-star comments contain keyword 'if' or 'for' #124

Closed FormerPhysicist closed 6 years ago

FormerPhysicist commented 6 years ago

When the slash-star comment style is used and the comment contains a keyword like "if" or "for", then the next line is incorrectly indented. For example,

/* Comment contains if */
    def foo = true

/* Comment contains for */
    def bar = true

/* Clean comment, no problem */
def x = false

// This is fine either way -> if for
def y = false

This appears in groovy mode version 2.1 and in emacs version 26.1

Looking at your code in groovy-mode.el, it looks like that the function groovy--prev-code-line is incorrectly returning the comment lines between / / as normal code to the function groovy-indent-line which is adding an additional indent level for the if or for blocks it "sees" in the comment.

I'll submit a merge request with what I think will fix the issue.

djlindstr commented 6 years ago

Fixed? :)

Wilfred commented 6 years ago

Yep.