Skip to content

ir does not contract selection #20

Open

Description

@radarek

Contracting selection does with ir not work for me (ar works just fine). I run tests and all passes. Here is example ruby file and simplest vimrc which reproduce bug in my computer.

module Foo
  class Bar
    def Baz
      [1, 2, 3].each do |i|
        i + 1
      end
    end
  end
end
set nocompatible
syntax on
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/

call vundle#begin('/tmp/vim/')
Plugin 'gmarik/Vundle.vim'
Plugin 'kana/vim-textobj-user'
Plugin 'nelstrom/vim-textobj-rubyblock'
call vundle#end()

filetype plugin indent on

runtime macros/matchit.vim

syntax on
filetype on
filetype plugin on
filetype indent on

Here are my steps:
gg
var
ir # this works OK, selection is reduced by 1 level
ir # this doesn't work

Any idea what may be wrong?

Activity

  1. sebroeder commented on Nov 15, 2014

    @sebroeder

    I have the same problem. For me not even the first ir works on the same sample code. The cursor jumps to the first line of the buffer but the selection does not change.

    I run the tests and they passed, however. So I have no idea where to look next :(

  2. lukelex commented on Nov 20, 2014

    @lukelex

    Is this still being maintained? I can't use any of the commands 😢

  3. jameslawson commented on Jan 29, 2015

    @jameslawson

    I'm also having the same problem.
    ir cannot contract selection past the first level.
    ar works fine - it can repeated expand selection.

  4. lmhsjackson commented on Jan 13, 2016

    @lmhsjackson

    Same original problem

  5. mattmartini commented on Oct 12, 2017

    @mattmartini

    I noticed something unexpected. Using var to highlight a block, then using ar and ir should expand and contract the selection. However ir does not contract the selection.

    Using your example:

    module Foo
      class Bar
        def baz
          [1,2,3].each do |i|
            i + 1
          end
        end
      end
    end
    
    1. Starting on the line with each and hitting vir the inside of the baz method is selected as expected.
    2. Now typing ar expands the selection to the whole baz method (from def to end).
    3. However, typing ir now does nothing.
    4. Typing ar at this point will expand the selection to the Bar class.
    5. Again ir does nothing at this point.
    6. Once again typing ar will expand the selection to the whole module.
    7. Now typing ir will shrink the selection to the inside of the module.
    8. At this point ar will expand to the whole module.
    9. Here ir ar will contract and expand the selection, but only at the top level. If we try to type ir twice it only contracts once.

    I suspect that because the blocks are nested once you are at 2. you have highlighted the baz method (around the previously selected inside) when you invoke ir it does nothing because it says you are already at the inside of the class Bar and therefore nothing happens.

    What is odd is that I used the same text as the video but the behavior is different. I tried this on a number of real world ruby files with the same effect.

    How do I troubleshoot this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions