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 240157 - Go to matching brace selects 'wrong' right-brace character
Summary: Go to matching brace selects 'wrong' right-brace character
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P4 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-09 11:50 UTC by RobertJohnson
Modified: 2015-11-06 02:29 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Image to show example of bad right-brace selection, cursor at position 4 should select the brace before it. (4.90 KB, image/png)
2014-01-09 11:50 UTC, RobertJohnson
Details
patch (2.65 KB, patch)
2015-10-29 13:49 UTC, junichi11
Details | Diff
patch v2 (12.44 KB, patch)
2015-11-03 12:59 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description RobertJohnson 2014-01-09 11:50:37 UTC
Created attachment 143747 [details]
Image to show example of bad right-brace selection, cursor at position 4 should select the brace before it.

Your matching brace technology is excellent - when the cursor is before *or after* a brace, it is assumed to be one end of a pair.

When the key to move to the matching brace is pressed, the cursor should find the matching brace, and if the key is repeated it should move back to the original brace - a cursor position toggle.

The problem is when there are 2 consecutive right-hand braces.

In the example picture attached, the brace before the cursor should be selected, not the one after it.

To demonstrate why, follow these instructions using the line in the attached picture:

1. Put the cursor at position 3.
2. Press 'matching-brace' key
3. Press 'matching-brace' again - the cursor returns to position 4, selecting the following brace.  The cursor position is correct, but the brace selection is wrong, and it is only a problem in this one scenario.
4. Further key presses move to a different pair of braces.

My suggestion is that when the cursor is positioned between 2 right-hand braces, the brace prior to the cursor should be selected, not the one after.

It becomes more important when the opposite brace is not visible in the editor.

By repeating the brace-match key, you should never switch to a pair of braces different to the one that was selected on the first key press.
Comment 1 junichi11 2015-10-29 13:49:55 UTC
Created attachment 157049 [details]
patch

I've created a patch. Thanks.
Comment 2 junichi11 2015-10-29 13:52:02 UTC
Could you please review it?

Thanks!
Comment 3 Tomas Mysik 2015-11-02 14:56:37 UTC
@junichi11: Please, would it be possible to add a test for it? Thanks.
Comment 4 junichi11 2015-11-03 04:15:39 UTC
(In reply to Tomas Mysik from comment #3)
> @junichi11: Please, would it be possible to add a test for it? Thanks.

I'll try it. I recreate a patch (with tests) because I would like to change my patch a little. Thanks.
Comment 5 junichi11 2015-11-03 12:59:12 UTC
Created attachment 157120 [details]
patch v2

I recreated a patch(added changes and tests).  Could you please review it? Thanks.
Comment 6 Tomas Mysik 2015-11-05 11:47:06 UTC
Patch applied, thanks a lot!

http://hg.netbeans.org/web-main/rev/2bb7640fc463
Comment 7 Quality Engineering 2015-11-06 02:29:35 UTC
Integrated into 'main-silver', will be available in build *201511060002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/2bb7640fc463
User: Tomas Mysik <tmysik@netbeans.org>
Log: #240157 - Go to matching brace selects 'wrong' right-brace character

Patch contributed by junichi11@netbeans.org.