| Summary: | Content assist gives strange proposal in a dictionary object | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Remy Suen <remy.suen> | ||||
| Component: | JS Tools | Assignee: | Michael Rennie <Michael_Rennie> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | curtis.windatt.public, Michael_Rennie, pahnke.sebastian | ||||
| Version: | 13.0 | ||||||
| Target Milestone: | 15.0 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 10 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
I don't get any proposals inside markdowns. Tern must be suggesting it from some pattern seen previously (possibly in a different file). I can reproduce in the CodeEditWidget. The key is include the line markdowns[s] If you just have the empty markdowns object, no proposals are shown (good). If you add the statement markdowns["abc"] you get the proposal "abc" inside the object literal (good). But with indirection step through the variable "s" you get the <i> proposal inside the object literal (bad). (In reply to Sebastian Pahnke from comment #2) > I can reproduce in the CodeEditWidget. > > The key is include the line > markdowns[s] > The problem can also be easily reproduced using the demo page: http://ternjs.net/doc/demo/index.html#simple and the snippet: var markdowns = { // assist here }; var s = "abc"; return markdowns[s]; The underlying reason looks like a combination of: 1. when the object is inferred, a placeholder property is added for 's', and, 2. when we ask for proposals, we also accept guessed proposals, which end up including the '<i>' stand-in. I'll open a bug against Tern to see if this is by design, or a bug that we can get fixed there. The Tern bug: https://github.com/ternjs/tern/issues/894 (In reply to Michael Rennie from comment #4) > The Tern bug: > > https://github.com/ternjs/tern/issues/894 The Tern bug has been fixed already. We can adopt the changes in our code for now until we update to a version of Tern with the fix in it. |
Created attachment 267248 [details] Image describing the error in question. orion.eclipse.org 1. Create a project. 2. Create a test.js file. 3. Put the following content in it. var markdowns = { // assist here }; var s = "abc"; return markdowns[s]; 4. Invoke content assist where the comment is. 5. You'll get a strange suggestion: <i> 6. Wrapping it in a function so it's more "realistic" doesn't help. You'll get the same problem. function x() { var markdowns = { // assist here }; var s = "abc"; return markdowns[s]; }