Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 506890

Summary: [Content assist] Completion is not working correctly for variable names containing $
Product: [ECD] Orion Reporter: Sebastian Pahnke <pahnke.sebastian>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: curtis.windatt.public, itaip6, Olivier_Thomann, steve_northover
Version: 13.0   
Target Milestone: 15.0   
Hardware: PC   
OS: Windows NT   
Whiteboard:

Description Sebastian Pahnke CLA 2016-11-02 07:58:00 EDT
Consider the following variable definition (which has a standards compliant name):

var $_test = 42;
//<-- content assist here (case 1)
$//<-- content assist here (case 2)
$_//<-- content assist here (case 3)

Case 1: works as expected
Case 2: Variable is shown in completion list but gets completed as $$test
Case 3: No completion is shown

All cases behave the same if a $ is somewhere inside the name. For case 3 the $ must be followed by the _.
Comment 1 Curtis Windatt CLA 2016-11-02 09:57:30 EDT
Olivier, could this be related to the wildcard matching or was that limited to * and ?
We might just have to update the valid characters list.
Comment 2 Steve Northover CLA 2017-03-29 17:45:51 EDT
If easy, please fix.  Otherwise, move back to P3.  Thanks!
Comment 3 Curtis Windatt CLA 2017-03-30 12:49:09 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=aed08836d161a456d3e687ffc9bc937c46ca667a
Fixed in master with tests

Two issues found. 1) $ is not a character when figuring out the prefix (causes case 3) and 2) The formatted proposal only uses a prefix set by Tern, ignoring the prefix we calculated in out tools (case 2).
Comment 4 Itai Pelles CLA 2017-07-31 08:58:41 EDT
Hey guys,

I ran into this problem once again but in a more complex situation, when filtering proposals.
The steps to reproduce:

1. Insert code:
var a$a1;
var a$a2;

2. Type "a$" then hit CTRL+SPACE to open content assist

3. You can see both a$a1 and a$a2 in the proposal list as expected

4. Type an additional 'a' character.

Expected result:
Both suggestions should still appear

Actual result:
Content assist is closed

I debugged the code and currently believe that the problem lies in this function:
https://github.com/eclipse/orion.client/blob/master/bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js#L466
Since the '$' sign is in the prefix, it does not get escaped. Therefore the created regex is bad and the proposals are filtered out.

What do you say about escaping the prefix as well as the filter?