Community
Participate
Working Groups
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 '/* ... */'
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.
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).
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).
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.
See also bug 373382.
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.
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
Sigh, yes, thanks...
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 .