| Summary: | TypeError thrown if incomplete proposal is returned for content assist | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Remy Suen <remy.suen> |
| Component: | Editor | Assignee: | Michael Rennie <Michael_Rennie> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | steve_northover |
| Version: | 13.0 | ||
| Target Milestone: | 15.0 | ||
| Hardware: | PC | ||
| OS: | Windows NT | ||
| Whiteboard: | |||
Mike, please investigate. Other badness may be happening here. Thanks. (In reply to Remy Suen from comment #0) > 1. Open the gitFilePlugin.js. > 2. Register the content assist service provider below. > We should be checking the positions, and ignoring ones that are missing information - then we also need to avoid trying to enter linked mode if there are no computed positions. (In reply to Steve Northover from comment #1) > Mike, please investigate. Other badness may be happening here. Thanks. No other badness - this really comes down to us being tolerant to missing (expected) information. Fixed in: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=78f12141319c2fc83423c3850eff6db621bf0f6d |
1. Open the gitFilePlugin.js. 2. Register the content assist service provider below. pluginProvider.registerServiceProvider("orion.edit.contentAssist", { computeProposals: function (buffer, offset, context) { return [ { proposal: "test", positions: [ { offset: offset } ], escapePosition: offset + 4 } ]; } }, { name: "Git Ignore Content Assist", contentType: ["text/x-git-ignore" ] }); 3. Self-host an Orion instance. 4. Open a .gitignore file. 5. Invoke Ctrl+Space 6. Apply the proposal. You will get the TypeError below. The error is caused by linkedMode.js trying to process the invalid linked mode position. https://github.com/eclipse/orion.client/blob/3f256ab112f1d3f127b674a8da63eee671e57e8a/bundles/org.eclipse.orion.client.editor/web/orion/editor/linkedMode.js#L408 Since the property doesn't exist, the end offset is flagged as NaN. https://github.com/eclipse/orion.client/blob/b371f07bd2769b14d65ee7ff59ae945e1ea1faa8/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js#L788 With such a strange selection defined for the editor, it eventually dies in the aforementioned TypeError. Instead of dying with such an obscure error, I feel like we should validate the proposal and either fail fast with an exception or to not bother trying to enter linked mode. https://github.com/eclipse/orion.client/blob/dab81ce4b8d974b274d74f1ef105770e8a7fa01b/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L1008-L1013 Uncaught TypeError: Cannot read property 'length' of null _getStyles @ textStyler.js:1325 _onLineStyle @ textStyler.js:1437 onLineStyle @ textStyler.js:978 _dispatchEvent @ eventTarget.js:82 dispatchEvent @ eventTarget.js:62 onLineStyle @ textView.js:2639 _createLine @ textView.js:666 create @ textView.js:656 _ensureCreated @ textView.js:910 getBoundingClientRect @ textView.js:914 _getBoundsAtOffset @ textView.js:6056 _showCaret @ textView.js:7200 _setSelection @ textView.js:6958 setSelection @ textView.js:3301 setSelection @ editor.js:797 selectLinkedGroup @ linkedMode.js:408 enterLinkedMode @ linkedMode.js:317 contentAssistProposalApplied @ actions.js:1015 _dispatchEvent @ eventTarget.js:82 dispatchEvent @ eventTarget.js:62 apply @ contentAssist.js:201 enter @ contentAssist.js:1101 (anonymous) @ contentAssist.js:871 invokeAction @ textView.js:2487 _doAction @ textView.js:4800 _handleKeyDown @ textView.js:3827 handler @ textView.js:6371