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 233896 - Patch for: Code completion does not recognize double single quote, inserts one too many
Summary: Patch for: Code completion does not recognize double single quote, inserts on...
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: SQL Editor (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal (vote)
Assignee: Libor Fischmeistr
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2013-08-03 16:58 UTC by everflux
Modified: 2013-08-20 07:58 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
proposed patch v1 (11.53 KB, patch)
2013-08-03 18:36 UTC, matthias42
Details | Diff
proposed patch v2 (9.19 KB, patch)
2013-08-03 19:57 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description everflux 2013-08-03 16:58:43 UTC
Product Version: NetBeans IDE Dev (Build 201308022300)
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15

I have an SQL file and edit it in Netbeans:

COL_IP_RANGE        VARCHAR(255)    NOT NULL DEFAULT ###

Cursor is placed at "###" and I type two single quotes  ''
Expected result: Two single quotes
Actual result: Three single quotes and Netbeans marks everything after the line as an error.
Comment 1 matthias42 2013-08-03 18:36:49 UTC
Created attachment 138233 [details]
proposed patch v1

The attached patch makes the behavior configurable via the Option: 

Tools->Options->Editor->Code Completion->All Languages->"Insert Closing Brackets Automatically"

From the documentation/help:

"Insert Closing Brackets Automatically. When selected, the Source Editor generates the closing parenthesis, bracket, brace, or quotation mark after you type the first one."

That is the right behavior.
Comment 2 matthias42 2013-08-03 18:38:55 UTC
Missing info: OptionsUtils.java is based on the identically named class from php.editor.
Comment 3 everflux 2013-08-03 18:45:49 UTC
I don't think this is quite the right behaviour, since we can have two distinct cases:
a) I indeed want to have it auto-closed and stop typing after the first '
b) I am so in the flow that I continue typing and type two ' - Netbeans should then not enter the "third" quote.

So the IDE should know what it just proposed - if it is the very same as the user is typing, it decide to overwrite the suggestion. (Like switching from insert to overwrite mode temporarily)

I would consider it a work-around to have to disable code completion to have the IDE not to interfere with my desired end result.
Comment 4 matthias42 2013-08-03 19:57:48 UTC
Created attachment 138236 [details]
proposed patch v2

I'm not sure whether I like this better, its realized in iteration 2: The SQLTypedTextInterceptor now also overrides the beforeInsert Method, the insertion of the new texts is intercepted if typed character is equal to the character following the caret and the situation is (| ist the caret when typing):

`|`
"|"
'|'
[|]

then the new character is not inserted and the caret is moved one character ahead.
Comment 5 Libor Fischmeistr 2013-08-20 07:58:02 UTC
Patch applied: http://hg.netbeans.org/core-main/rev/ff42dd1c943b

Matthias thank you for that patch.