Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle comment for current line via CMD + / #241

Merged
merged 37 commits into from
Apr 25, 2024

Conversation

Sophiahooley
Copy link
Contributor

@Sophiahooley Sophiahooley commented Apr 19, 2024

This change implements the functionality of / for single line comments. It allows you to toggle between commented and uncommented for the line the cursor is currently on when you press /.

To do so, I implemented a keyDown event recognizer, which listens for when the relevant keys are pressed. If / is pressed, it calls a method called commandSlashCalled(), which decides which toggle is supposed to happen depending on if the line is already commented or not. It also addresses the situation of special cases of languages like HTML, which need a comment at the beginning and end of the line (essentially a rangeComment) to comment a single line.

Related Issues

This PR accomplishes part of #38. I talked with some of the project leads (@FastestMolasses) and they said it makes sense to break #38 into a couple different issues (I.e. single-line vs highlighted chunks, etc). Single-line comment toggling is completed as of this PR but commenting highlighted code still needs to be completed.

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Screenshot 2024-04-19 at 5 44 24 PM

@Sophiahooley Sophiahooley changed the title Comment out line cursor is on via CMD + / Toggle comment for current line via CMD + / Apr 19, 2024
Copy link
Collaborator

@thecoolwinter thecoolwinter left a comment

Choose a reason for hiding this comment

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

Awesome work, this is close to being ready with a few small things. I left some comments. Some are small organization things (where to put methods, etc) and a few are bugs (responding to commands when unfocused, commenting lines with whitespace). Looks good so far, thanks for the contribution!

@austincondiff
Copy link
Collaborator

Please fix SwiftLint errors

@austincondiff
Copy link
Collaborator

It looks like we have some failing tests.

@thecoolwinter
Copy link
Collaborator

Looks like the problem is CELangs didn't get a release, so the required comment properties don't exist for the referenced version. I'll update CELangs and push the change to this repo, then merging from main should fix the problem.

@thecoolwinter
Copy link
Collaborator

@Sophiahooley if you merge from main it should fix the error the test runner is hitting

Copy link
Collaborator

@thecoolwinter thecoolwinter left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@thecoolwinter thecoolwinter merged commit dae56c8 into CodeEditApp:main Apr 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants