[Geany-devel] Auto-close parenthesis - ID: 2957958 Need Info
elextr at xxxxx
Tue Nov 2 00:39:42 UTC 2010
On 2 November 2010 05:16, shan chak <shankholove at gmail.com> wrote:
> Referring to bug Auto-close parenthesis - ID: 2957958 (
> 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.
> 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
> Geany-devel mailing list
> Geany-devel at uvena.de
More information about the Devel