carymrobbins / intellij-haskforce

Haskell plugin for IntelliJ IDEA
http://carymrobbins.github.io/intellij-haskforce/
Apache License 2.0
486 stars 39 forks source link

Double-click on Haddock '-- |' comment selects whole line #198

Open orome opened 9 years ago

orome commented 9 years ago

Double-clicking on a Haddock comment beginning with '-- |' selects the whole line, rather than the word under the cursor. Selecting a word in such a comment can only be done manually.

carymrobbins commented 9 years ago

What's odd is that this only happens with -- | haddocks and not -- ^. This seems like it may be a bug upstream. Either way, this led me to fix a bug with the lexing of haddocks, which means that they will be properly highlighted now as doc comments, as of the next release, v0.3-beta.24.

carymrobbins commented 8 years ago

The latest release is out, so closing this. Please reopen if you still experience the issue.

orome commented 8 years ago

This seems worse now. Double-clicking still selects the whole line, but now, in addition, if I hit return in a line beginning with -- |, the comment is not continued, and the insertion point jumps to the end of the first word on the new line.

carymrobbins commented 8 years ago

@orome - Ouch, I'll take a look at it.

orome commented 8 years ago

Also the first line (with the -- |) is colored differently from remaining lines (preceded by just --) in the same comment.

orome commented 8 years ago

@carymrobbins — Have you been able to confirm the color issue? (It persists in the latest update for me.)

carymrobbins commented 8 years ago

Yes, the color issue can be pretty easily resolved by changing around how we lex haddock comments. See commit https://github.com/carymrobbins/intellij-haskforce/commit/d31aa9b3e40820d51b9716d173708b0b0c80f01f which implements this.

However, the double-click issue still persists. My guess is that we're parsing it as a PsiComment but we actually need to be parsing it as a PsiDocComment. What's strange is that other PsiComment elements don't seem to have this issue (e.g. the -- comments), so I'm not sure what's triggering it in this context.

orome commented 8 years ago

@carymrobbins — Cool, thanks! The selection is wired, but not as much of an problem day-to-day as the coloring is (was).

orome commented 8 years ago

@carymrobbins — FWIW, it seems that double-clicking in white space in a doc-comment in any JetBrains IDE selects the whole comment.

carymrobbins commented 8 years ago

Yes, but ideally double-clicking a word shouldn't. I noticed when looking at the parse tree for Java and Scala that the PsiDocComment has child nodes, so that may aid in resolving the problem.

Are you building from source? Wondering since you might have been inferring that you were using a build based off of my referenced commit.

orome commented 8 years ago

@carymrobbins — No, I'm sticking with releases that JetBrains has.

carymrobbins commented 8 years ago

It seems that my possible fix for the lexing/coloring issue is causing some parse errors somewhere else in the layout; although, it's a bit hard to track down since it works with the IntelliJ test runner and fails with ant (both locally and on travis). For reference, the latest version of that commit is 69729e5 , but I'll be pulling it out before making the next release until I can figure out what's going wrong.

orome commented 8 years ago

Yes, I've seen this behavior (doc comments behaving this way) elsewhere now; not in HaskForce, but in a different language in one of the JetBrains IDEs. But I didn't have the presence of mind to note where!

carymrobbins commented 8 years ago

Good to know it's not just me. Looking at the Java AST it seems that they are breaking out the elements differently, so once I do some deeper parsing of the haddock AST this issue will probably be resolved.