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

✨ Comment out highlighted code #38

Open
jenslys opened this issue Apr 24, 2022 · 10 comments
Open

✨ Comment out highlighted code #38

jenslys opened this issue Apr 24, 2022 · 10 comments
Assignees
Labels
editor enhancement New feature or request good first issue Good for newcomers

Comments

@jenslys
Copy link

jenslys commented Apr 24, 2022

Description

/ should allows users to toggle between commented and uncommented for the line the cursor is currently on when you press /.

If a selection is made on a single line, a range comment should be used.

Comment placement styles…

/* Xcode - At leading end of leading whitespace */
func hi() {
    print("Hi")
//    print("Hi")
}

/* Android Studio - Inset at leading end of leading whitespace */
func hi() {
    print("Hi")
//  print("Hi")
}

/* VS Code - At trailing end of leading whitespace */
func hi() {
    print("Hi")
    // print("Hi")
}

/* Inset at trailing end of leading whitespace */
func hi() {
    print("Hi")
 // print("Hi")
}

We should allow for all three styles via a Setting:

Comment Placement:

  • At leading end of leading whitespace
  • Inset at leading end of leading whitespace
  • At trailing end of leading whitespace
  • Inset at trailing end of leading whitespace

Describe the solution you'd like

Ability to comment out code by highlighting some code and pressing: /

Additional context

hightlight

@jenslys jenslys added the enhancement New feature or request label Apr 24, 2022
@lukepistrol lukepistrol added good first issue Good for newcomers editor labels Apr 24, 2022
@guga1109
Copy link

Hi, I would like to work on this issue as my first contribuition :)

@austincondiff
Copy link
Collaborator

@lukepistrol does this depend on the new editor being in place or can this be worked on now? Different languages have different ways of commenting code, so will this depend on tree sitter, language grammars, or the LSP?

@lukepistrol
Copy link
Member

This should be implemented in CodeEditTextView directly.

@austincondiff austincondiff transferred this issue from CodeEditApp/CodeEdit Jun 25, 2022
@crpatil1901
Copy link

Can you assign this issue to me? I would like to start contributing to this project

@austincondiff
Copy link
Collaborator

Done! Let me know if you have any questions.

@Sophiahooley
Copy link
Contributor

How is this going @crpatil1901 @austincondiff? I would be interesting in working on this also if no solution has been found yet.

@austincondiff
Copy link
Collaborator

@Sophiahooley I can assign it to you. This related PR is about to be merged just so you are aware.

@Sophiahooley
Copy link
Contributor

Do you know if the PR is going to be merged soon? I am trying to see if I should start working now or if the related PR will completely change what I do.

thecoolwinter pushed a commit that referenced this issue Apr 25, 2024
This change implements the functionality of <kbd>⌘</kbd> <kbd>/</kbd>
for single line comments. It allows you to toggle between commented and
uncommented for the line the cursor is currently on when you press
<kbd>⌘</kbd> <kbd>/</kbd>.

To do so, I implemented a `keyDown` event recognizer, which listens for
when the relevant keys are pressed. If <kbd>⌘</kbd> <kbd>/</kbd> 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

- #38

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

- [x] I read and understood the [contributing
guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md)
as well as the [code of
conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md)
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code

### Screenshots

<img width="626" alt="Screenshot 2024-04-19 at 5 44 24 PM"
src="https://github.com/CodeEditApp/CodeEditSourceEditor/assets/143217945/1200a5c1-d8ea-48a4-9704-70db7aa23fc7">

---------

Co-authored-by: Abe <[email protected]>
@austincondiff
Copy link
Collaborator

Can we close this or do we still need to update CESE version in CodeEdit?

@thecoolwinter
Copy link
Collaborator

Still need to update, and this is 1/2 done. Still needs multi-line commenting implemented as well as detecting comment type in context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor enhancement New feature or request good first issue Good for newcomers
Projects
Status: 🏃‍♂️ In Progress
Development

No branches or pull requests

7 participants