-
Notifications
You must be signed in to change notification settings - Fork 84
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
Conversation
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Outdated
Show resolved
Hide resolved
Please fix SwiftLint errors |
It looks like we have some failing tests. |
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. |
@Sophiahooley if you merge from main it should fix the error the test runner is hitting |
There was a problem hiding this 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!
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 calledcommandSlashCalled()
, 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 arangeComment
) 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
Screenshots