lppedd/idea-conventional-commit

New syntax highlighting doesn't work with git "staging area" enabled

Gerrit-K opened this issue ยท 11 comments

I really loved to read about the new syntax highlighting and other language-related features, but it seems that it doesn't work when the git "staging area" is enabled (Preferences > Version Control > Git > Enable staging area). Turning it off and on turns the highlighting on an off accordingly. I hope this is not a bug in the IDE itself, though ...

Hey! TBH with you I didn't even know IDEA had a staging area now ๐Ÿ‘€ will look into it tonight but I think it's solvable.

Does it cause exceptions or other visible issues?

Hehe, thanks for looking into it :) I think it dropped in the 2021 version, but wasn't promoted so much. But for someone like me, who likes to switch between the IDE and the command line to perform git actions, it's quite useful. Plus: it allows you to selectively stage hunks and lines and directly edit the staged content (where "stage" is meant in the real git context, i.e. the index).

But back to topic, no, I didn't see any errors, exceptions or other visible issues. The (standard) completions also works fine for both settings, as far as I can tell. It's just not highlighted.

The staging area is well hidden in code. Tricky. I could override the EditorTextFieldProvider, but that is used by the entire IDE.
Another prototype that may work, but that's madness

project.messageBus.connect().also {
      ...
      it.subscribe(ToolWindowManagerListener.TOPIC, object : ToolWindowManagerListener {
        override fun toolWindowShown(toolWindow: ToolWindow) {
          if (toolWindow.id == "Commit") {
            val contentManager = toolWindow.contentManager
            contentManager.addContentManagerListener(object : ContentManagerListener {
              override fun contentAdded(event: ContentManagerEvent) {
                val content = event.content
                content.addPropertyChangeListener { e ->
                  if (e.propertyName == Content.PROP_COMPONENT) {
                    if (e.newValue != null && e.newValue::class.java.simpleName == "GitStagePanel") {
                      // Get and cache the EditorTextField 
                    }
                  }
                }
              }
            })
          }
        }
      })
    }

I'll just override EditorTextFieldProvider. I've weighted the alternatives, and that's the best one.

I don't think I'll be able to deliver 0.21.1 before the next two weeks unfortunately.

Hey @lppedd , sorry for the late reply. Don't worry about that :) It's not urgent at all, but I highly appreciate your fast response and commitment! Looking forward to the next release, whenever it will drop :)

Fixed with commit 0c16916

Now the Conventional Commit language is always injected in the text editor.
When the "highlight syntax" option is disabled, the lexer simply returns normal text token types, so they won't be highlighted.

bric3 commented

I'm not sure this is fixed in 2022.3 the commit text area is not syntax highlighted (when the git staging area is enabled).

image

But disabling the staging area, syntax highlighting is working again
image

@bric3 it's probably not fixed yet as the latest release is from June 7th and I opened this issue on June 8th, so the fix is most likely unreleased yet.

@lppedd is that correct? If so, is there a chance to ship another release? :)

@Gerrit-K it is indeed correct. 2023.1 is approaching and I need to ship a new version otherwise it's not gonna work.