naomi icon indicating copy to clipboard operation
naomi copied to clipboard

jsx uncomment not work

Open luckmonkey opened this issue 7 years ago • 23 comments

jsx uncomment not work

luckmonkey avatar Nov 24 '17 08:11 luckmonkey

I sent some commits on the master branch to fix the issue for single line comments. Unfortunately for multi line comments I still have no solution.

borela avatar Nov 24 '17 18:11 borela

img_16_01_11 38 31_be6ef9f6e8f In-tag comments isn't highlighted (as comments) too :)

faiwer avatar Jan 16 '18 05:01 faiwer

I'll have to use python scripts to fix the comment toggle. I'll give it a shot this week.

borela avatar Jan 16 '18 10:01 borela

@faiwer Is that valid syntax? Normally on JSX you would have to do something like: {/* comment */}

borela avatar Jan 17 '18 17:01 borela

@borela, I don't know exactly, but it works in babel :) Aslo eslint shows the parsing error: unexpected token in the next code:

<Tag {/* comment */}/>

How do you can comment line in an attribute jsx section another way?

faiwer avatar Jan 17 '18 17:01 faiwer

@faiwer Babel is indeed parsing comments directly, love it!

I released a patch https://github.com/borela/naomi/releases/tag/v3.1.0 that will highlight // and //* near attributes.

Comment toggling is wrong yet specially for attributes.

borela avatar Jan 17 '18 18:01 borela

Thank you!

faiwer avatar Jan 17 '18 18:01 faiwer

JSX toggle comment still can't work image image

Ding-Fan avatar Mar 01 '18 14:03 Ding-Fan

@Ding-Fan I am researching the sublime api to fix this one through a plugin.

borela avatar Mar 01 '18 14:03 borela

I created a plugin https://github.com/borela/naomi/pull/92 that should be able to toggle JS/JSX comments, the code is here https://github.com/borela/naomi/blob/feature/comment-toggle-plugin/plugin/ToggleJsxComment.py

I would love feedback before merging and realeasing it, can you guys take a look at it? I did some tests locally and tried to fine tune it to get the UX right (it turns out, coding such feature is not intuitive at all).

@luckmonkey @faiwer @Ding-Fan

borela avatar Mar 07 '18 19:03 borela

I don't know how to use the single .py file with sublime3 so I removed Naomi through "Package Control: Remove Package", followed Manual Installation installed it, restarted Sublime3.

Nothing changed.

Ding-Fan avatar Mar 07 '18 22:03 Ding-Fan

@Ding-Fan You need to clone the repository or download the package through github https://github.com/borela/naomi/archive/feature/comment-toggle-plugin.zip at the directory:

  • OS X: ~/Library/Application Support/Sublime Text 3/Packages
  • Linux: ~/.config/sublime-text-3/Packages
  • Windows: %APPDATA%\Sublime Text 3\Packages

borela avatar Mar 07 '18 22:03 borela

I am doing some final tweaks, it looks like I got most edge cases, almost ready to release it.

borela avatar Mar 07 '18 22:03 borela

I did some tests and it looks like it is detecting correctly when to add the braces even for block comments, released it: https://github.com/borela/naomi/releases/tag/v3.8.0 package control should pick the update in about ~2h.

Feel free to reopen this issue or open new ones if it causes regression.

borela avatar Mar 07 '18 23:03 borela

Not working at all for me 🤔

naomi-jsx-comments

Naomi 3.10.1

franciscolourenco avatar Mar 09 '18 10:03 franciscolourenco

@franciscolourenco I'll take a look at it at the office.

borela avatar Mar 09 '18 11:03 borela

@franciscolourenco Please check if the console (View > Show Console) shows an error when you try to comment, I am not able to reproduce it on my machine.

borela avatar Mar 09 '18 11:03 borela

@borela no errors. I'm using Sublime 3133, what about you?

franciscolourenco avatar Mar 09 '18 11:03 franciscolourenco

3157 I'll try with an older version.

borela avatar Mar 09 '18 11:03 borela

Just tried with 3143 but got the same results

franciscolourenco avatar Mar 09 '18 12:03 franciscolourenco

Found the issue, I forgot to override the shortcut for macs, the line https://github.com/borela/naomi/blob/master/Default.sublime-keymap#L229 only works for Linux and Windows while the default package uses:

	{ "keys": ["super+forward_slash"], "command": "toggle_comment", "args": { "block": false } },
	{ "keys": ["super+alt+forward_slash"], "command": "toggle_comment", "args": { "block": true } },

for mac.

I'll publish the patch in a minute.

borela avatar Mar 09 '18 12:03 borela

@franciscolourenco https://github.com/borela/naomi/compare/v3.10.1...v3.10.2 published the patch, as the shortcut for OSX was not replaced, in your case, it was using sublime's default behavior. It should be working now.

borela avatar Mar 09 '18 12:03 borela

In Sublime 4 you can't uncomment a rxjs line when your cursor position is at the end, it simply recomments that line image

boycce avatar Aug 24 '22 00:08 boycce