Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 145830 - css values completion gets closed while having no space after previous value
css values completion gets closed while having no space after previous value
Status: VERIFIED FIXED
Product: editor
Classification: Unclassified
Component: CSL (API & infrastructure)
6.x
Sun All
: P3 (vote)
: 6.x
Assigned To: issues@editor
issues@editor
: NETFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-01 16:49 UTC by Jindrich Sedek
Modified: 2010-04-28 13:36 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Patch for excluding comma as a prefix returned by CssCompletion#getPrefix(TokenSequence,int) (715 bytes, patch)
2010-04-02 21:04 UTC, kapitarg
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jindrich Sedek 2008-09-01 16:49:56 UTC
use this code:
----------------
h1{
    azimuth: behind,|
}
-----------------
invoke cc -> some items appear
pres c to reduce the list -> the cc window disapears

note:
it works with space
----------------
h1{
    azimuth: behind, |
}
-----------------

it works with one more character (type e):
----------------
h1{
    azimuth: behind,c|
}
-----------------
Comment 1 Marek Fukala 2008-09-24 13:12:09 UTC
CssCompletion bug.
Comment 2 David Konecny 2008-11-12 23:23:58 UTC
Too late for 65.
Comment 3 Marek Fukala 2009-11-06 09:47:01 UTC
GsfCompletionProvider.canFilter() bug.

On line 388 there is following code: filterPrefix = isJavaIdentifierPart(language, prefix) ? prefix : null;

In this issue case the filterPrefix becomes null and then in GCP.filter() the completion windows is just closed if
filteredPrefix == null;

I do not even understand the logic why canFilter() returns true if the filteredPrefix is null so I better leave the fix
on CSL experts.
Comment 4 Jiri Kovalsky 2010-03-26 14:47:42 UTC
This issue was added to the list of NetFIX [1] candidates. If module owner does not agree, please speak up. Thanks!

[1] http://wiki.netbeans.org/NetFIXIssues
Comment 5 kapitarg 2010-04-02 21:04:28 UTC
Created attachment 96625 [details]
Patch for excluding comma as a prefix returned by CssCompletion#getPrefix(TokenSequence,int)

In example [1], the GsfCompletionProvider:388 isJavaIdentifierPart() is called with "c" as the second argument. This makes the variable "filterPrefix" a not empty string, so everything is fine.

However in example [2] ",c" is used. Since comma is not part of any identifier, the variable "filterPrefix" will be null, and the cc window will close.

example [1]:
----------------
h1{
    azimuth: behind, |
}
-----------------
invoke cc -> some items appear
pres c to reduce the list

example [2]:
----------------
h1{
    azimuth: behind,|
}
-----------------

The reason why ",c" is used is a bit complicated.
The value ",c" is retrieved from the document text using offsets. In example [2] the "anchorOffset" field is one position behind, because it is calculated in GsfCompletionProvider:590 like offset - prefix length. And the prefix is coming from CssCompletion.getPrefix() (line 791) which is the comma itself.

So excluding the comma as a prefix makes both examples work. Also the JUnit tests run without problems. However I'm not 100% sure that this solution has no side effects. Could you please have a look?
Comment 6 Vitezslav Stejskal 2010-04-08 05:48:47 UTC
http://hg.netbeans.org/jet-main/rev/71a90fc1d2b1

Thanks for the patch!
Comment 7 Jiri Kovalsky 2010-04-08 07:09:26 UTC
Thanks Vito and especially thanks Gabor for your patch!
Comment 8 Marek Fukala 2010-04-08 13:15:38 UTC
> In this issue case the filterPrefix becomes null and then in GCP.filter() the
> completion windows is just closed if
> filteredPrefix == null;
> 
> I do not even understand the logic why canFilter() returns true if the
> filteredPrefix is null so I better leave the fix
> on CSL experts.

Thanks for the fix in the css editor. 

I just want to point out that the problem with canFilter() returning true if filterPrefix == null is still there. The consequence is that the filter() method is then called but fails since the filterPrefix == null. If canFilter() returned false, which is IMHO what it should in such case do, the normal completion query would be run and the results would be returned correctly.

The fix done by Gabor is definitively correct, and since there seems not to be any user impact of the problem above anymore I consider the issue as marginal.
Comment 9 Quality Engineering 2010-04-09 04:43:05 UTC
Integrated into 'main-golden', will be available in build *201004090201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/71a90fc1d2b1
User: Vita Stejskal <vstejskal@netbeans.org>
Log: #145830: applying kapitarg's patch fixing code completion in CSS editor
Comment 10 Jindrich Sedek 2010-04-28 13:36:31 UTC
verified.
NetBeans IDE Dev (Build 201004270201)


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo