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

Commenting problem #108702

Closed
IMPrimph opened this issue Oct 15, 2020 · 16 comments
Closed

Commenting problem #108702

IMPrimph opened this issue Oct 15, 2020 · 16 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@IMPrimph
Copy link

IMPrimph commented Oct 15, 2020

We have written the needed data into your clipboard because
Issue Type: Bug

In any CSS file, if I wrote some code and comment on it for the first time, it works fine.
But, when I write some more code and select all the parts (previously commented part "using Ctrl + A")and comment again, it's not working.

VS Code version: Code 1.50.1 (d2e414d, 2020-10-13T15:06:15.712Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz (8 x 1190)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 7.70GB (3.00GB free)
Process Argv --crash-reporter-id d387dc60-c945-40be-a4f1-77fe9107addc
Screen Reader no
VM 0%
Extensions (10)
Extension Author (truncated) Version
vscode-eslint dba 2.1.10
vsc-material-theme Equ 33.0.0
vsc-material-theme-icons equ 1.2.0
prettier-vscode esb 5.7.1
beautify Hoo 1.5.0
vscode-nuget-package-manager jmr 1.1.6
vscode-csharp-snippets jor 0.3.1
csharp ms- 1.23.3
python ms- 2020.9.114305
vscode-icons vsc 11.0.0

(1 theme extensions excluded)

@hDmtP
Copy link

hDmtP commented Oct 15, 2020

@IMPrimph exactly same case here. In fact sometimes while writing CSS code under the style tag in an HTML code when I select some part of the CSS code and press ctrl+/ to comment it uses HTML comment(i.e. ) instead of CSS comment(/* /). I have to manually type / */ to get my job done. I don't know if it's a fault in the settings of in the VS code.

@IMPrimph
Copy link
Author

@hDmtP
Exactly, can't figure out the problem. Might be a bug.

@aeschli
Copy link
Contributor

aeschli commented Oct 15, 2020

Can you add small code sample with steps that show what's not working?

@aeschli aeschli added the info-needed Issue requires more information from poster label Oct 15, 2020
@IMPrimph
Copy link
Author

IMPrimph commented Oct 15, 2020

@aeschli
This is the first part of the code I have written and commented:

/* body {
  font-family: "Open Sans", sans-serif;
}

h1 {
  text-align: center;
} */

Then I wrote some more code:

/* body {
  font-family: "Open Sans", sans-serif;
}

h1 {
  text-align: center;
} */

#container div {
  width: 200px;
  height: 200px;
  text-align: center;
  font-size: 3em;
}

And now, when I tried to select all(Ctrl + A) and comment at once(Ctrl + /), the code is not getting commented:

/* body {
  font-family: "Open Sans", sans-serif;
}

h1 {
  text-align: center;
} */

#container div {
  width: 200px;
  height: 200px;
  text-align: center;
  font-size: 3em;
} */

Please check these four images for a clear explanation:
Starting code
Starting code commented
Added some more code
Then commented it

@hDmtP
Copy link

hDmtP commented Oct 15, 2020

@aeschli

  1. The code
    Screenshot 2020-10-15 175401
  2. I selected some CSS code under the <style> tag in the HTML code
    Screenshot 2020-10-15 175503
  3. As I pressed ctrl+/ to comment out it uses the HTML comment tag() instead of CSS comment tag(/* */)
    Screenshot 2020-10-15 175632
  4. This is the manually typed comment of the same code
    Screenshot 2020-10-15 175950

Note: The ctrl+/ is working in an individual .css file. I have also noticed that the shortcut also works in CSS code, embedded in an HTML code. But in my VS code, this process isn't working(as shown above). I will be thankful to know if it is a bug or a settings issue in my VS code.

@aeschli
Copy link
Contributor

aeschli commented Oct 15, 2020

@IMPrimph That's how the commenting feature works. It just adds comment tokens (e.g. /* */) around the selected block, without processing the content.
To uncomment a block you must select just that comment.

@hDmtP That's an unrelated issue, but I'm not able to reproduce what you are seeing. I get the proper CSS comments /* */ when in CSS. Is the language mode html (check the status bar on the right). Does it reproduce with extensions disabled?

@hDmtP
Copy link

hDmtP commented Oct 15, 2020

@aeschli Yes the language mode is HTML and it reproduces with extensions disabled.

@IMPrimph
Copy link
Author

@aeschli
I am not uncommenting.
See, when we write some 100lines of CSS at first and then comment it.
Again wrote 100 lines of CSS and use CTRL + A and comment. The previous 100 lines are commented well, but the next 100 lines are not getting commented on.
That is what I have depicted in the images.

@gjsjohnmurray
Copy link
Contributor

Slightly related to #107989. @aeschli can commenting logic easily discover language of code at cursor?

@hDmtP
Copy link

hDmtP commented Oct 16, 2020

@gjsjohnmurray
Yeah, I also want to confirm this.

@aeschli
Copy link
Contributor

aeschli commented Oct 16, 2020

Then commented it

@IMPrimph As seen in the screen shot, all the comment action does is adding the comment tokens (`/*` `*/`). The commented content is intentionally not modified, e.g. no closing comment token ( `*/`) is escaped. that's left to the user. That's how the comment command is intended to work.

@aeschli
Copy link
Contributor

aeschli commented Oct 16, 2020

@gjsjohnmurray I don't see how this is related to #107989.

@gjsjohnmurray
Copy link
Contributor

@hDmtP works OK for me:

junk

Or have I misunderstood your problem?

@aeschli ignore my previous comment. I now see block commenting is already smart enough to use the correct languageId

const languageId = model.getLanguageIdAtPosition(startLineNumber, startColumn);

@hDmtP
Copy link

hDmtP commented Oct 16, 2020

Not only you @gjsjohnmurray I have also seen this feature working in other's VS code. But hell knows why negative in case of mine.

@KamasamaK
Copy link

@hDmtP Can you highlight the same text, open the command palette, select "Developer: Inspect Editor Tokens and Scopes" and post a screenshot?

@aeschli
Copy link
Contributor

aeschli commented Nov 5, 2020

This issue has diverted into various topics. I believe the original issue was based on a misunderstanding. I'll close this and would be happy if new issues with code sample and reproducible steps are filed.

@aeschli aeschli closed this as completed Nov 5, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants