Skip to content

ruby-block-send sends unexpected block #171

@bo-tato

Description

@bo-tato
begin
  puts "outer" # cursor on this line
  begin
    puts "inner"
  end
  puts "outer again"
end

here if we do ruby send block with the cursor on the first puts "outer", I think expected behavior is to send the block containing puts "outer" but it sends puts "inner" block, as ruby-send-block is using ruby-end-of-block which uses ruby-move-to-block which moves to what it calls the sibling block, in other words just the next end statement, not the end of the block containing the cursor.
Another unexpected behavior is when the cursor is on the ending line of a block:

begin
  puts "first block"
end # cursor on this line
begin
  puts "second block"
end

with the cursor on the end line of the first block, ruby- block-send sends the second block.

In https://github.com/bo-tato/inf-ruby/tree/fix-ruby-send-block I change ruby-send-block to use er/ruby-forward-up which gives the behavior I'd expect for both those cases. I don't open a pull request as that introduces a dependency on expand-region package that I assume is undesired. If it's desired to change ruby-send-block to behave like this I can try to code it without adding extra dependency

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions