This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 243951 - Auto-complete doesn't overwrite the existing content
Summary: Auto-complete doesn't overwrite the existing content
Status: REOPENED
Alias: None
Product: third-party
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: _ rkubacki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-20 19:07 UTC by csbubbles
Modified: 2016-07-14 01:50 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Before auto-complete (53.32 KB, image/png)
2014-04-20 19:07 UTC, csbubbles
Details
After auto-complete (55.83 KB, image/png)
2014-04-20 19:08 UTC, csbubbles
Details
auto suggestion (240.85 KB, image/png)
2014-08-13 03:33 UTC, csbubbles
Details
after suggestion selected (149.12 KB, image/png)
2014-08-13 03:34 UTC, csbubbles
Details
1 - create project (82.88 KB, image/png)
2014-09-13 22:18 UTC, csbubbles
Details
2 - write code (128.60 KB, image/png)
2014-09-13 22:19 UTC, csbubbles
Details
3 - check autocompletion (202.23 KB, image/png)
2014-09-13 22:19 UTC, csbubbles
Details
4 - results (130.15 KB, image/png)
2014-09-13 22:19 UTC, csbubbles
Details
Use case 1 - Step 1 (134.49 KB, image/png)
2016-01-31 19:14 UTC, csbubbles
Details
Use case 1 - Step 2 (209.73 KB, image/png)
2016-01-31 19:15 UTC, csbubbles
Details
Use case 1 - Step 3 (129.02 KB, image/png)
2016-01-31 19:15 UTC, csbubbles
Details
Use case 2 - Step 1 (131.33 KB, image/png)
2016-01-31 19:16 UTC, csbubbles
Details
Use case 2 - Step 2 (224.41 KB, image/png)
2016-01-31 19:16 UTC, csbubbles
Details
Use case 2 - Step 3 (128.53 KB, image/png)
2016-01-31 19:16 UTC, csbubbles
Details

Note You need to log in before you can comment on or make changes to this bug.
Description csbubbles 2014-04-20 19:07:32 UTC
I am facing this issue while editing Android's XML resources, but I believe that this is just a general issue with XML as NetBeans would handle all the XML files same way.

1. Create an xml file like shown below (img1):

--
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView android:layout_width="fill" />
</RelativeLayout>
---

Please note that "fill" value is not valid in the Android resource schema.

2. Now put your text cursor between 'fill' attribute value and the second double quote, and press Ctrl-Space. The editor will autocomplete the attribute with the valid "fill_parent" value, but will not delete "fill" entered before, so you will get "fill_parentfill" instead of expected "fill_parent" (img2).

--
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView android:layout_width="fill_parentfill" />
</RelativeLayout>
---

Try to play with different attributes and stuff, but in general it will work same way, keeping the attribute entered before auto completion.

The expected behavior is to completely overwrite everything what has been in the attribute value.

PS Please consider this issue as a higher priority, because from my personal view the autocomplete functionality for XML attributes is just totally broken. It is much easier currently just to enter valid values manually. If you are using use auto-completion there, you always get wrong replacement and need to take care of watching and fixing it on your own, which doesn't make sense for "auto" completion at all.
Comment 1 csbubbles 2014-04-20 19:07:58 UTC
Created attachment 146848 [details]
Before auto-complete
Comment 2 csbubbles 2014-04-20 19:08:19 UTC
Created attachment 146849 [details]
After auto-complete
Comment 3 Svata Dedic 2014-07-14 14:00:37 UTC
Hi; do you use some specific module to assist with Android development ? I am asking since XML completion is schema-driven, and there's (according to https://groups.google.com/forum/#!topic/android-developers/2FtsLQ4wESY) no real schema for the android namespace you use. If you have some XML schema, please attach it here.

I've tried to complete in a Spring beans document (with a xml schema) and completion for enumeration-style attributes worked OK: even ambiguous value prefix was correctly overwritten by the completed enum value.
Comment 4 csbubbles 2014-08-13 03:32:49 UTC
I have no clue about schemas, to be honest. What I can tell you is that the schema does exist, as when you press Ctrl/Cmd-Space, it shows you available options (see 1.png attached). But after selecting one and pressing Enter, the previously written text is not getting replaced, but added at the end of the selected suggestion (see 2.png attached).
Comment 5 csbubbles 2014-08-13 03:33:33 UTC
Created attachment 148665 [details]
auto suggestion
Comment 6 csbubbles 2014-08-13 03:34:01 UTC
Created attachment 148666 [details]
after suggestion selected
Comment 7 csbubbles 2014-08-13 03:36:22 UTC
(In reply to csbubbles from comment #4)
> I have no clue about schemas, to be honest. What I can tell you is that the
> schema does exist, as when you press Ctrl/Cmd-Space, it shows you available
> options (see 1.png attached). But after selecting one and pressing Enter,
> the previously written text is not getting replaced, but added at the end of
> the selected suggestion (see 2.png attached).

PS 1.png => "auto suggestion", 2.png => "after suggestion selected"

I don't think the Android plugin override the default xml editor behavior, so it is expected to work anyway, regardless of how the schema is defined, as it find suggestions for all the attributes somehow.
Comment 8 csbubbles 2014-09-13 22:18:55 UTC
Created attachment 149194 [details]
1 - create project
Comment 9 csbubbles 2014-09-13 22:19:11 UTC
Created attachment 149195 [details]
2 - write code
Comment 10 csbubbles 2014-09-13 22:19:37 UTC
Created attachment 149196 [details]
3 - check autocompletion
Comment 11 csbubbles 2014-09-13 22:19:50 UTC
Created attachment 149197 [details]
4 - results
Comment 12 csbubbles 2014-09-13 22:31:44 UTC
This auto-completion issues doesn't seem to be XML editor related, so I have modified the title and the component. You can reproduce it with Java as well following these steps:

1. Create a new Java Application peoject ("1 - create project" png attached)
2. Write some code ("2 - write code" png attached; create two objects AbstractCollection and AbstractList to get both classed in the imports section for the further auto-complete)
3. Place your text cursor between Abstract and Collection words for the AbstractCollection class and press "Cmd+Space" or"Ctrl+Space" on Win/Linux ("3 - check autocompletion" png attached)
4. Select AbstractList from the suggestion popup and press "Return/Enter".

[Results]

AbstractListCollection

[Expected results]

AbstractCollection

[Impact]

Very poor usability. Each time you use auto-complete after you have already entered something, you have to remove manually what is left after. In fact, in most cases it's easier to type manually instead of using the current auto-complete functionality.

[Proposed solution]

When replacing stuff with autocompletion, remove everything from the current position till the next separation token (space, period, comma, etc.)
Comment 13 csbubbles 2014-09-13 22:32:44 UTC
Sorry, a typo. The expected result would be "AbstractList" of course, not "AbstractCollection".


(In reply to csbubbles from comment #12)
> This auto-completion issues doesn't seem to be XML editor related, so I have
> modified the title and the component. You can reproduce it with Java as well
> following these steps:
> 
> 1. Create a new Java Application peoject ("1 - create project" png attached)
> 2. Write some code ("2 - write code" png attached; create two objects
> AbstractCollection and AbstractList to get both classed in the imports
> section for the further auto-complete)
> 3. Place your text cursor between Abstract and Collection words for the
> AbstractCollection class and press "Cmd+Space" or"Ctrl+Space" on Win/Linux
> ("3 - check autocompletion" png attached)
> 4. Select AbstractList from the suggestion popup and press "Return/Enter".
> 
> [Results]
> 
> AbstractListCollection
> 
> [Expected results]
> 
> AbstractCollection
> 
> [Impact]
> 
> Very poor usability. Each time you use auto-complete after you have already
> entered something, you have to remove manually what is left after. In fact,
> in most cases it's easier to type manually instead of using the current
> auto-complete functionality.
> 
> [Proposed solution]
> 
> When replacing stuff with autocompletion, remove everything from the current
> position till the next separation token (space, period, comma, etc.)
Comment 14 Svata Dedic 2014-09-14 06:34:32 UTC
Please do not different situations in one defect report. Append new information only for the same specific situation, otherwise open a new defect report.
The bug described by original part and the part appended at 9/2014 target completely unrelated pieces of code (XML, java completion). 

Always file a separate report for each found defect, especially in different languages, windows, file types file. Defects are easy to duplicate or link together, but harder to split. Thanks.
Comment 15 Svata Dedic 2014-09-14 06:36:24 UTC
Additional note: do not change component after the initial evaluation (we usually move the defect to the correct area during initial eval) unless you *know* where the code that causes or is suspected for the defect is located.
Comment 16 Svata Dedic 2014-09-14 06:42:10 UTC
I split the java related part to issue #247097
Comment 17 csbubbles 2014-09-14 06:53:38 UTC
Hi Svata,

From the user perspective there is the only issue - the auto-completion works unexpectedly in the text editor not replacing the wrong term. This is not user's business whether NetBeans has implemented various editors through multiple components and has same bugs in different ones. I believe this is the project manager' and developers' responsibility to analyze the feedback provided by users and create as many tickets as they want for those components they think that would b appropriate.

Thanks,
Maxim. 


(In reply to Svata Dedic from comment #14)
> Please do not different situations in one defect report. Append new
> information only for the same specific situation, otherwise open a new
> defect report.
> The bug described by original part and the part appended at 9/2014 target
> completely unrelated pieces of code (XML, java completion). 
> 
> Always file a separate report for each found defect, especially in different
> languages, windows, file types file. Defects are easy to duplicate or link
> together, but harder to split. Thanks.
Comment 18 csbubbles 2014-09-14 06:58:18 UTC
This one makes sense, I will follow what you wrote here next time. Thanks.

(In reply to Svata Dedic from comment #15)
> Additional note: do not change component after the initial evaluation (we
> usually move the defect to the correct area during initial eval) unless you
> *know* where the code that causes or is suspected for the defect is located.
Comment 19 Svata Dedic 2015-04-24 12:28:20 UTC
OK, I reproduced the reported issue with XML completion on Ant files as well. it seems that XML schema-provided enumeration values are OK, but grammar providers have some issue (Android module delivers a special grammar provider for XML completion).
Comment 20 Svata Dedic 2015-04-24 14:16:20 UTC
Fixed in jet-main#ac41114f04ae


Tested on attribute values, node contents. I hope the fix won't break other providers, the API details are rather underspecified.
Comment 21 Quality Engineering 2015-05-12 03:25:56 UTC
Integrated into 'main-silver', will be available in build *201505120001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ac41114f04ae
User: Svata Dedic <sdedic@netbeans.org>
Log: #243951: attr values wrongly stripped suffix - providers serve full value strings
Comment 22 csbubbles 2016-01-31 19:14:56 UTC
Created attachment 158315 [details]
Use case 1 - Step 1
Comment 23 csbubbles 2016-01-31 19:15:22 UTC
Created attachment 158316 [details]
Use case 1 - Step 2
Comment 24 csbubbles 2016-01-31 19:15:41 UTC
Created attachment 158317 [details]
Use case 1 - Step 3
Comment 25 csbubbles 2016-01-31 19:16:00 UTC
Created attachment 158318 [details]
Use case 2 - Step 1
Comment 26 csbubbles 2016-01-31 19:16:16 UTC
Created attachment 158319 [details]
Use case 2 - Step 2
Comment 27 csbubbles 2016-01-31 19:16:31 UTC
Created attachment 158320 [details]
Use case 2 - Step 3
Comment 28 csbubbles 2016-01-31 19:20:21 UTC
It's not really fixed, but actually got even worse in 8.1. Please find the 6 new attachment that show 2 use cases - 1) the replacement of an existing attribute value, and 2) entering a new value. This behaves like crazy... In the first case, a new value still doesn't replace the previous one but basically works just like it was explain in the initial bug description - it erases some part from the previous value and keep the other part. In the second case there is some weird merge happening with the next line.

Product Version: NetBeans IDE 8.1 (Build 201510222201)
Java: 1.8.0_20; Java HotSpot(TM) 64-Bit Server VM 25.20-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_20-b26
System: Mac OS X version 10.11.3 running on x86_64; UTF-8; en_US (nb)
Comment 29 csbubbles 2016-01-31 19:29:23 UTC
I've tried to create Spring's beans xml file, an attribute's new value doesn't override the old value either. It behaves differently, but instead of replacing the old value with the new one, it simply merges them.
Comment 30 Svata Dedic 2016-06-24 11:18:33 UTC
So ... I've fixed a few bugs and will be fixing some more, but no bug in 'core' supports is so fatal as in your usecase #2.

It's partially because Android has its own provider of completion items, which may be faulty in some aspects.

I will hand off this issue to nbandroid product after I fix inconsistencies in core XML modules.
Comment 31 Svata Dedic 2016-06-24 13:50:48 UTC
I suggest that SimpleText in the grammars module returns -1 from getLength(). See issue #249496 and relevant changes.
Comment 32 Quality Engineering 2016-07-14 01:50:42 UTC
Integrated into 'main-silver', will be available in build *201607140002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/9b93f2e9263b
User: Svata Dedic <sdedic@netbeans.org>
Log: #243951: improved consistency between schema-based and Grammar-based completion. Usability improved for schema-based completion