brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] Fixing several Block and Line Comment issues #2238

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by TomMalbran Wednesday Dec 12, 2012 at 19:47 GMT Originally opened as https://github.com/adobe/brackets/pull/2342


This pull request fixes both issues mentioned in adobe/brackets#2339, one of them being a line comment issue and the other a block comment issue and the 6/7 and 9/10 inconsistency mentioned in adobe/brackets#2337 since that really wasn't an intended behavior.


TomMalbran included the following code: https://github.com/adobe/brackets/pull/2342/commits

core-ai-bot commented 3 years ago

Comment by peterflynn Thursday Dec 13, 2012 at 19:22 GMT


A few issues I noticed in testing:

core-ai-bot commented 3 years ago

Comment by TomMalbran Thursday Dec 13, 2012 at 20:41 GMT


If you are allowed to block comment with any selection of a mix of code + line comment, even when doing a block comment might uncomment part of the line comments, it makes things easier to check. This should then work for all the cases mentioned above.

core-ai-bot commented 3 years ago

Comment by peterflynn Friday Dec 14, 2012 at 02:52 GMT


I've created a big suite of unit tests for line comment that I hope will be helpful: see pflynn/block-comment-unittests (it's not on master yet since they're not all passing).

It's still hitting two things that I think are bugs, but almost all the tests pass with your latest commit.

One problem seems to with looking at the char or token after the end of the selection:

The other is related to selections that end at ch:0. The behavior varies depending on what's on that line, when it probably shouldn't matter (because the selection doesn't include any chars from that line; just the CR ending the previous line).

If you'd like to use my unit tests for testing your changes, you could use a procedure like this:

  1. Checkout my branch from upstream (creating a local tracking branch)
  2. Merge your branch into it
  3. Run the unit tests & modify your code as needed
  4. git stash save
  5. Checkout your branch
  6. git stash apply and then commit your changes

(This way you can use my tests before they've landed in master, without getting them stuck in your branch & thus your pull request)

core-ai-bot commented 3 years ago

Comment by TomMalbran Friday Dec 14, 2012 at 05:04 GMT


I fixed the code so that it passed the 3 failed unit tests and every other test.

core-ai-bot commented 3 years ago

Comment by peterflynn Friday Dec 14, 2012 at 22:37 GMT


@TomMalbran: Done reviewing. Looks good except for those two nits about the boolean operation.

Btw -- unrelated to this pull request -- I was wondering if you could tell me more about the block of code that starts with else if (startCtx.token.className === null &&... I'm a little confused by it. Tokens with className == null aren't "invalid" or otherwise special (they're just uncolored text like operators, commas, semicolons, whitespace, etc.). It seems like we really only need that case to handle whitespace (because it has className == null, it's harder to tell if we're inside an existing block comment). Am I interpreting it correctly?

core-ai-bot commented 3 years ago

Comment by TomMalbran Friday Dec 14, 2012 at 23:04 GMT


Yes I am using that to check if the start of the selection is in a whitespace before the text. So then it can be used to uncomment line comments of multiple block comments, but when the start of the selection is after the first line of the block comment and before the start of the line, since here it still has className === null. Maybe a better check would be !startCtx.token.className && startCtx.token.string.trim().length === 0 to just check for white spaces, like is done in Token Utils.

core-ai-bot commented 3 years ago

Comment by TomMalbran Friday Dec 14, 2012 at 23:26 GMT


Changes done.

core-ai-bot commented 3 years ago

Comment by peterflynn Saturday Dec 15, 2012 at 00:01 GMT


Looks great -- thanks again! Merging now (whew!)