<div class="gmail_quote">Hi,<br>Thanks Lex,<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> The problem is in file editor.c function auto_close_char Line:1397<br>
><br>
> In the switch-case block the ifs have a compulsory condition which is<br>
> end_pos == -1 , as far as I understand end_pos is the current position of<br>
> the brace ( caret ) returned by SSM(sci, SCI_BRACEMATCH, pos, 0) and when<br>
> the second opening brace is typed the end_pos becomes >0 so the code never<br>
> enters the if block. Just by removing the condition the problem is fixed.I<br>
> was unable to get why that specific condition was added, can anybody please<br>
> help me here?<br>
<br>
</div>I haven't analyzed it carefully, but I think what it is trying to do<br>
is to only add a new close bracket only if one is needed.  If<br>
sci_find_matching_brace finds a match then it won't add one, whereas<br>
if there is no matching close bracket then one will be added.<br>
<br>
Of course the use case shown in the bug shows this is flawed in some<br>
cases, but in other cases its useful eg if the end == -1 wasn't there<br>
<br>
a = ( b + 1 ? c : d ) + 1  oops I need a bracket around the b+1<br>
<br>
type the (<br>
<br>
a = ( () b + 1 ? c : d ) + 1  ...  !@#$%^&*()<br>
<br>
So you can't win, no simple algorithm is right all the time.  I guess<br>
the autoclose users need to decide which is more useful (I don't use<br>
it so I don't care)<br><div class="im"></div></blockquote><div><br>I missed this case. Surely its pretty annoying.<br>Now if we see how eclipse implement this  , it will never autocomplete the braces  for cases like these:<br>
a = (  b + 1 ? c : d ) + 1 <br>Now if we type the bracket around b+1 then <br>a = ( ( b + 1 ? c : d ) + 1<br>and let the user decide how to close it.<br>The algorithm is complex taking into consideration many corner cases. <br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
><br>
> Also if there is auto completion of braces when a '(' is typed why there is<br>
> no auto removal of ')' when a brace is deleted?<br>
<br>
</div>No one wrote the code, patches are welcome, but beware of similar<br>
issues to above.  Actually I think this patch may not be welcome since<br>
silently deleting characters is *bad*.<br>
<div class="im"><br></div></blockquote><div>Yeah its bad, but take the case:<br>A user inputs '(' and ')' is automatically added, now what if user deletes the '(' , he/she also has to delete the ')'. I think in such cases its not a big risk to delete the ')'. Like the above case if there is any character in between '(' and ')' let the user decide.<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
><br>
> I am sorry if the mail looks pretty unprofessional but I have just begun to<br>
> learn geany code base.<br>
<br>
</div>No problem.<br>
<br></blockquote><div>Eagerly waiting for your comments.<br><br>Thank you<br>shankhs<br></div></div>