Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Line comment bug fix #11954

Merged
merged 18 commits into from
Feb 13, 2016
Merged

Line comment bug fix #11954

merged 18 commits into from
Feb 13, 2016

Conversation

heysupratim
Copy link
Contributor

Better line comment toggling , initiates the line comment at the start of the code and maintains the position of the cursor throughout (like sublime )

Better for lint to comment indents

Affected me so hence changed it

Will fail some editorCommandHandler tests which expect the line comment at the start of the line

fix for #11953 (comment)

@abose abose added this to the Release 1.6 milestone Nov 25, 2015
@abose
Copy link
Contributor

abose commented Nov 25, 2015

@borax12 Thanks for contributing to brackets.
There is a slight issue here
linecommentbug
When you include a selection with uneven cursor position, it tries to comment out in the wrong place, and toggle comment breaks.
This could be fixed if you analyze the left most line position in the selection and then use that position for inserting the comments.

@heysupratim
Copy link
Contributor Author

Ah , i see, checking it out

@heysupratim
Copy link
Contributor Author

@abose i had to push extra commits due to some code formatting issues . Hope it works now

@abose
Copy link
Contributor

abose commented Nov 25, 2015

unit tests for editor command handlers fails after this change. The unit tests needs to be modified with the new commenting structure.

@heysupratim
Copy link
Contributor Author

@abose - Rewrote the test cases , The editor command handler Unit Test Cases Pass now

@redmunds
Copy link
Contributor

It looks like you're changing it so that inline comments are always indented. Is that correct?

This needs to be a preference because some languages (VBScript, PHP, bash?) require that inline comment delimiter is in the first column. Then you'll need tests for both cases.

@heysupratim
Copy link
Contributor Author

@redmunds yeah it is always indented . I checked the behaviour in ST2 for php and bash scripts - they are also always indented .

Does brackets have per language based preferences ?

@abose
Copy link
Contributor

abose commented Nov 26, 2015

🆒 Verified, all unit tests passing now.
You could have a preference like
"dontIntentComments" {"languages":['bash']} ..
With reasonable defaultpreferences set for languages.

@redmunds
Copy link
Contributor

You could have a preference like "dontIntentComments" {"languages":['bash']}

Brackets already has a mechanism for specifying language specific preferences, so no need to invent a new one. Take a look at this example in the How to Use Brackets doc, especially the "language" section:

    "language": {
        "javascript": {
            ...
        }
    },

As far as what to call the new preference, it depends on what the default is. Since the current default is not to indent, then a name like indentInlineComments would be consistent with existing behavior since prefs that are not defined, evaluate to "falsy". If we want to change the default to be indented, then maybe dontIndentInlineComments.

Don't forget to add new preference to Preferences section of the How to Use Brackets doc and also to the defaultPreferences.json file.

@heysupratim
Copy link
Contributor Author

@redmunds @abose - Ohk , will take a bit of time as i need to see how preference loading and initiating works in brackets . but i will have to research which languages take line comment indentation by default

@TomMalbran
Copy link
Contributor

If some languages require that the comments start on the first column, it should be a property of the language definition and not a preference. There can be a preference if an user decides to overwrite such behaviour or wants to go back to have comments at the start of a line.

@abose
Copy link
Contributor

abose commented Nov 28, 2015

Never knew that language based pref existed 😅 Thanks @redmunds @TomMalbran

@redmunds
Copy link
Contributor

@borax12 There is already PR #11574 that looks like it fixes the same issue.

@marcelgerber What's the status of your PR?

@abose
Copy link
Contributor

abose commented Dec 1, 2015

@borax12 Could you also look at #11574 and see if Your implementation has any functionality difference with it.
#11574 also doesn't seem to implement any unit tests.

@heysupratim
Copy link
Contributor Author

i will do that @Arun . I have been trying to get the per language
based setting correctly . I will also look at #11574

On 12/1/15, Arun Bose notifications@github.com wrote:

@borax12 Could you also look at #11574 and see if Your implementation has
any functionality difference with it.
#11574 also doesn't seem to implement any unit tests.


Reply to this email directly or view it on GitHub:
#11954 (comment)

[image: Supratim Chakraborty on about.me]

Supratim Chakraborty
about.me/borax12
http://about.me/borax12

@abose
Copy link
Contributor

abose commented Dec 8, 2015

@borax12 Did you get any chance to look into the isues? This is a very good usability improvement that we could ship as part of 1.6 coming late december or early jan.

@heysupratim
Copy link
Contributor Author

@petetnt - i separated the test cases with one set making it run with preference set to true and other making it run on preference set to false

@heysupratim
Copy link
Contributor Author

@petetnt - is there anything else needed on this , just needed an update :)

@petetnt
Copy link
Collaborator

petetnt commented Jan 29, 2016

Sorry @borax12, I have been swamped with work so I haven't had the time to review the latest commit. I'll do it tomorrow morning if that is okay with you 👍

@heysupratim
Copy link
Contributor Author

no worries there @petetnt - appreciate the update .And regarding the work . I hope it turns out the best for you :)

@heysupratim
Copy link
Contributor Author

@petetnt - updates? :)

@abose abose modified the milestones: Release 1.7, Release 1.6 Feb 1, 2016
beforeEach(setupFullEditor);
describe("Line comment/uncomment with indentLineComment enabled", function () {

beforeEach(function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: Indentation with the beforeEach and afterEach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petetnt -what exactly needs to be indented here ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about being vague: I mean that there's extra indentation within this function block:

        beforeEach(function () {
                setupFullEditor();
                PreferencesManager.set("indentLineComment",true);
            });

Should be:

        beforeEach(function () {
            setupFullEditor();
            PreferencesManager.set("indentLineComment",true);
        });

@petetnt
Copy link
Collaborator

petetnt commented Feb 1, 2016

@borax12 Sorry for taking so long 🐌

I made some more comments, mostly just style nitpicks but there was a single test that wasn't changed to split format later in the file too.

@heysupratim
Copy link
Contributor Author

@petetnt - i made the final changes , split the two tests and tried to address the top mentioned style nits , hopefully this should do it :)

…commentindent feature- that was a tough one month
@heysupratim
Copy link
Contributor Author

@petetnt - hey man , i must be bugging you , but i did split the changes, i guess that should do it

@petetnt
Copy link
Collaborator

petetnt commented Feb 7, 2016

LGTM /cc @abose

@abose
Copy link
Contributor

abose commented Feb 11, 2016

Thanks @borax12 @petetnt .Will check this out over the weekend .

abose added a commit that referenced this pull request Feb 13, 2016
@abose abose merged commit 8e49f35 into adobe:master Feb 13, 2016
@abose
Copy link
Contributor

abose commented Feb 13, 2016

LGTM. Verified all the test cases hilighted.
Thanks very much for this change @borax12
Merging. 🎆

@heysupratim
Copy link
Contributor Author

cool @abose - looking forward to contributing more :)

@abose
Copy link
Contributor

abose commented Feb 14, 2016

@borax12 If you are interested in contributing to new features in brackets, please take a look at our trello board to see features requested by the community.
If you are interested in fixing something more immediate, Many unit tests are failing, which needs to be fixed 😅

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants