lppedd / idea-conventional-commit

Context and template-based completion for conventional/semantic commits.
https://plugins.jetbrains.com/plugin/13389-conventional-commit
MIT License
327 stars 19 forks source link

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

Closed Gerrit-K closed 2 years ago

Gerrit-K commented 2 years ago

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 ...

lppedd commented 2 years ago

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?

Gerrit-K commented 2 years ago

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.

lppedd commented 2 years ago

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 
                    }
                  }
                }
              }
            })
          }
        }
      })
    }
lppedd commented 2 years ago

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

lppedd commented 2 years ago

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

Gerrit-K commented 2 years ago

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 :)

lppedd commented 2 years ago

Fixed with commit 0c169160c29c7f45f9d9b42ea7cc468f11ad539d

lppedd commented 2 years ago

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 1 year ago

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

Gerrit-K commented 1 year ago

@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? :)

lppedd commented 1 year ago

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