This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 469939 - [HTML][CSS] JavaScript comment shortcut incorrectly applied to HTML & CSS
Summary: [HTML][CSS] JavaScript comment shortcut incorrectly applied to HTML & CSS
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Client (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 11.0   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-11 09:37 EDT by Jefferson Lam CLA
Modified: 2016-01-11 11:37 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jefferson Lam CLA 2015-06-11 09:37:24 EDT
1. Open Orion to any HTML or CSS file
2. Click onto any line in the file
3. Press Cmd + /
4. BUG: '//' commenting (JavaScript commenting) is inserted. For HTML, it should be '<!-- ... -->' and for CSS it should be '/* ... */'
Comment 1 Grant Gayed CLA 2015-06-11 12:03:26 EDT
Note that every language grammar contains the plaintext representation of its comment syntaxes, so hopefully it's possible to create a solution to this that works for all of Orion's 25+ supported (syntax-styled) languages.  The language grammars are defined in the various syntax.js files.
Comment 2 Grant Gayed CLA 2015-06-11 12:13:23 EDT
Also consider cases of embedded languages (eg.- <script>/<style> blocks in html).  The syntax styler can be asked for the hierarchy of styles at any given editor index, so it should be possible to determine this generically (again, we have many cases of language embedding, not just html).
Comment 3 Curtis Windatt CLA 2015-06-30 12:07:08 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/?h=cwindatt%2FBug469939_WrongLineComments

I pushed our initial work to a branch.  On top of what Jefferson and I worked on I added a new function to the styler to look for a matching pattern.  However, it does not return any of the line comments I expected (instead returning swift and TODOs).
Comment 4 Curtis Windatt CLA 2015-06-30 16:25:26 EDT
Another potential approach we could take is to allow plug-ins to contribute editor commands for content types.  The editor commands in actions.js would then lookup service references or contributed commands with a specific id and delegate to them instead of the default operation.

The biggest benefit of this approach would be customizing behaviour.  For example in HTML Ctrl+/ could comment out a tag and all of it's contents.
Comment 5 Carolyn MacLeod CLA 2015-12-14 11:53:34 EST
See also bug 373382.
Comment 6 Grant Gayed CLA 2016-01-08 15:49:38 EST
Fixed, commit: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=99c00022de9e4b7ae0cf7bc34f77d284626770b8 .

The editor actions to add/remove block comments and to toggle line comments have been updated to use the language-specific comment delimiters for all languages.  This includes embedded language cases like js and css within html.  The comment delimiters come from the language grammars.

This does not preclude an approach like the one described in comment 4 being adopted in the future, this would just be the default behaviour in the absence of a plug-in contributed action.
Comment 7 Curtis Windatt CLA 2016-01-11 10:12:08 EST
Reopening as this change is the likely cause of the test failures:

4 tests failed.
FAILED:  OS_X_10.10_safari_8.js_tests_editor_editorTests.TextStyler text/x-jade.Initial Styles

Error Message:
expected false to equal true

Stack Trace:
assert@http://orion-test.mybluemix.net/chai/chai.js:918:70
equal@http://orion-test.mybluemix.net/chai/chai.js:2334:16
http://orion-test.mybluemix.net/js-tests/editor/textStyler/textStylerTests.js:157:17
callFn@http://orion-test.mybluemix.net/mocha/mocha.js:4338:25
run@http://orion-test.mybluemix.net/mocha/mocha.js:4331:13
runTest@http://orion-test.mybluemix.net/mocha/mocha.js:4728:13
http://orion-test.mybluemix.net/mocha/mocha.js:4806:19
next@http://orion-test.mybluemix.net/mocha/mocha.js:4653:16
http://orion-test.mybluemix.net/mocha/mocha.js:4663:11
next@http://orion-test.mybluemix.net/mocha/mocha.js:4601:25
http://orion-test.mybluemix.net/mocha/mocha.js:4630:9
timeslice@http://orion-test.mybluemix.net/mocha/mocha.js:5761:27

FAILED:  Windows_7_chrome_43.js_tests_editor_editorTests.TextStyler text/x-jade.Initial Styles

Error Message:
expected false to equal true

Stack Trace:
AssertionError: expected false to equal true

FAILED:  Windows_7_internet_explorer_11.js_tests_editor_editorTests.TextStyler text/x-jade.Initial Styles

Error Message:
expected false to equal true

Stack Trace:
AssertionError: expected false to equal true
   at Assertion.prototype.assert (http://orion-test.mybluemix.net/chai/chai.js:914:7)
   at assert.equal (http://orion-test.mybluemix.net/chai/chai.js:2334:5)
   at Anonymous function (http://orion-test.mybluemix.net/js-tests/editor/textStyler/textStylerTests.js:157:5)
   at callFn (http://orion-test.mybluemix.net/mocha/mocha.js:4338:5)
   at Runnable.prototype.run (http://orion-test.mybluemix.net/mocha/mocha.js:4331:7)
   at Runner.prototype.runTest (http://orion-test.mybluemix.net/mocha/mocha.js:4728:5)
   at Anonymous function (http://orion-test.mybluemix.net/mocha/mocha.js:4806:7)
   at next (http://orion-test.mybluemix.net/mocha/mocha.js:4653:7)
   at Anonymous function (http://orion-test.mybluemix.net/mocha/mocha.js:4663:7)
   at next (http://orion-test.mybluemix.net/mocha/mocha.js:4601:16)

FAILED:  linux_firefox_38.js_tests_editor_editorTests.TextStyler text/x-jade.Initial Styles

Error Message:
expected false to equal true
Comment 8 Grant Gayed CLA 2016-01-11 10:16:25 EST
Sigh, yes, thanks...
Comment 9 Grant Gayed CLA 2016-01-11 11:37:39 EST
Tests updated to reflect styling changes that were introduced by updates to the jade grammar, commit: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=4c61f36f755a303fe5822b4bad59dca4eef7692f .