Hi
I'm unsure of the rationale for why plusminus is picky about where the cursor is when you try to collapse something. As fas as I can see, if you ask it to collapse something, it should try its hardest to. You could try the following code - dunno if it works with python though.
_command void my_hide_code_block() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
// Check to see if the very last command executed is the same command:
int expandBlock = 0;
_str name = name_name( prev_index( '', 'C' ) );
if ( name == "hide-code-block" || name == "my-hide-code-block" ) expandBlock = 1;
//say( '******* name='name );
//Check if the first non-blank character of this line is a comment
save_pos(auto p);
first_non_blank();
if (_clex_find(0,'g')==CFG_COMMENT) {
hide_comments();
return;
}
restore_pos(p);
int status=cs_hide_code_block( expandBlock );
if (!status && select_active()) {
hide_selection();
restore_pos(p);
} else {
down();
down();
prev_tag('', 'A');
// try again
down();
hide_code_block();
}
// Make this command the last command executed:
last_index( find_index( 'hide_code_block', COMMAND_TYPE ), 'C' );
}
_command void my_plusminus() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
if (plusminus())
my_hide_code_block();
}