bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.
BSD 3-Clause "New" or "Revised" License
1.12k stars 259 forks source link

Fix #570 - Behaviour of ToggleCommentAction #572

Open sesquialtera87 opened 1 month ago

sesquialtera87 commented 1 month ago

I tried to solve the comment-mark identification by ToggleCommentAction. Basically, the use of startsWith and endsWith methods allowed only to search for comment-marks at position 0 and line.length()-1, not recognizing in this way comments like

_______<!-- underscores are whitespaces -->_______

where some whitespaces are present before or after the marks.

Instead of the startsWith and endsWith, I introduced two methods looking for mark by skipping leading or trailing whitespaces. Now de-comment a code like this work as expected (previously another comment would have been inserted)

   <tag>
      <!-- <b>text</b> -->
   </tag>
   <tag>
       <b>text</b> 
   </tag>

I hope it can be useful

bobbylight commented 1 month ago

@sesquialtera87 can you rebase and fix the merge conflicts here? I'd be interested in adding this fix to the next release.

bobbylight commented 2 weeks ago

@sesquialtera87 I hate to ask this, but can you remove all the formatting changes? They're making this PR much larger than it should be and obfuscating the actual change.

sesquialtera87 commented 2 weeks ago

No problem. In the next few days I'll try to restore the formatting and include only the new code, without touching anything else in the code

sesquialtera87 commented 6 days ago

I'm struggling with Git... I removed every formatting stuff except my own relevant changing to the code, but after committing into this branch or merging with other clean branches I still see into the diff the unusefull IDE reformat insertions.

So, I created a new branch with only the relevant changes to ToggleCommentAction and in this new branch everything work. I dont' know if it's possible to associate to this pull request the new branch I've created. If you think so, I can create a new pull request from the new branch and close this.

Lastly, I include the corrections to the errors reported by the last CodeQL/Gradle analysis. Screenshot 2024-11-20 155410 I think those now are fixed.