[Geany-devel] Auto-close parenthesis - ID: 2957958 Need Info

Lex Trotman elextr at xxxxx
Tue Nov 2 00:39:42 UTC 2010


On 2 November 2010 05:16, shan chak <shankholove at gmail.com> wrote:
> Hi,
> Referring to bug Auto-close parenthesis - ID: 2957958 (
> https://sourceforge.net/tracker/?func=detail&aid=2957958&group_id=153444&atid=787791
> )
> I successfully reproduced the issue and was able to debug it.

Great, thank you.

> The problem is in file editor.c function auto_close_char Line:1397
>
> In the switch-case block the ifs have a compulsory condition which is
> end_pos == -1 , as far as I understand end_pos is the current position of
> the brace ( caret ) returned by SSM(sci, SCI_BRACEMATCH, pos, 0) and when
> the second opening brace is typed the end_pos becomes >0 so the code never
> enters the if block. Just by removing the condition the problem is fixed.I
> was unable to get why that specific condition was added, can anybody please
> help me here?

I haven't analyzed it carefully, but I think what it is trying to do
is to only add a new close bracket only if one is needed.  If
sci_find_matching_brace finds a match then it won't add one, whereas
if there is no matching close bracket then one will be added.

Of course the use case shown in the bug shows this is flawed in some
cases, but in other cases its useful eg if the end == -1 wasn't there

a = ( b + 1 ? c : d ) + 1  oops I need a bracket around the b+1

type the (

a = ( () b + 1 ? c : d ) + 1  ...  !@#$%^&*()

So you can't win, no simple algorithm is right all the time.  I guess
the autoclose users need to decide which is more useful (I don't use
it so I don't care)

>
> Also if there is auto completion of braces when a '(' is typed why there is
> no auto removal of ')' when a brace is deleted?

No one wrote the code, patches are welcome, but beware of similar
issues to above.  Actually I think this patch may not be welcome since
silently deleting characters is *bad*.

>
> I am sorry if the mail looks pretty unprofessional but I have just begun to
> learn geany code base.

No problem.

Cheers
Lex

> Can anybody please assign the bug to me? I dont know how to do it in SF I
> think only the Project admins can do it.
> Any help is appreciated.
>
> Thank you
> shankhs
>
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>
>



More information about the Devel mailing list