#659 Option to turn off matching bracket search for auto close

v1.23
open
nobody
5
2014-03-19
2013-03-27
tsherif
No

A similar issue was reported as a bug here: https://sourceforge.net/tracker/index.php?func=detail&aid=3082521&group_id=153444&atid=787791

I left a comment there about a possible fix, but since that issue was closed I thought I'd suggest a way to make the bracket auto closing a bit more usable. The problem is that for what Geany considers brackets - () {} [] - a search is done all the way to the end of file for a match, and if that match is found the closing is not done. The code that handles this is in src/editor.c, in the function auto_close_chars() at lines 1475-1476:
if (utils_isbrace(c, 0))
end_pos = sci_find_matching_brace(sci, pos - 1);

This renders the auto closing pretty much useless for brackets since any kind of nested block or function call will not auto close, and these are not uncommon. My suggestion would be either to take this bracket search out completely (I really don't see what its use is) by removing the aforementioned code, or if some users want it to remain, add an option to turn off the search, and then you can change the code in editor.c to:
if(do_closing_bracket_search && utils_isbrace(c, 0))
end_pos = sci_find_matching_brace(sci, pos - 1);

I'm using Geany 1.22 on Linux Mint 14.

Discussion

  • RonW
    RonW
    2014-03-19

    This matching also makes auto close of ( less useful when typing expressions like:

    ((x > ll) && (x < ul))

     
  • Lex Trotman
    Lex Trotman
    2014-03-19

    You could try the autoclose plugin.