RubyBlockConverter icon indicating copy to clipboard operation
RubyBlockConverter copied to clipboard

Highlighting part or all of an inner block should toggle that block

Open gstaubli opened this issue 11 years ago • 3 comments

If I have nested blocks and highlight the inner block (whether by having my cursor on the block's starting line or highlighting the entire block), it would be great to have that inner block toggled.

Example:

    10.times do |n|
        start_process(n) do
            puts "Processing #{n}, please wait..."
        end
    end

This would then become (if my cursor is touching the beginning or another part of #start_process or the entire block is highlighted):

    10.times do |n|
        start_process(n) { puts "Processing #{n}, please wait..." }
    end

gstaubli avatar Aug 20 '13 22:08 gstaubli

the command works on the blocks which surrounds a cursor. that is, when your cursor is on the "d" of the inner do, the block will be toggled. instead, if your cursor is on the first "s" of start_process, the surrounding block would be the outer one. Is it clear?

now what behavior do you like? "the block works on the surrounding block, but if the line has a "do" after the cursor, the latter will be toggled"?

irohiroki avatar Aug 21 '13 02:08 irohiroki

I would like it to toggle the inner block if any part of that blocks lines are selected by the cursor.

So there would be two scenarios to toggle the inner block:

  1. Any of the lines pertaining to the inner block have the cursor (lines 3-5).

  2. The inner block is highlighted (lines 3-5)

#2 may be contained within #1. I don't know what the behavior should be if the inner block is highlighted but other lines are highlighted too that do not pertain to the inner block.

gstaubli avatar Aug 21 '13 16:08 gstaubli

do you like that behavior on braces, too? multiple brace blocks can be on a line. which block should be toggled? I just started thinking that that could be too complicated to meet your wish. we need a simple and solid rule.

irohiroki avatar Aug 22 '13 00:08 irohiroki