Skip to content

Conversation

@rob-anderson
Copy link

Hi Drew

Thanks for your time yesterday - lots of new vim toys to play with.

As I mentioned in the class, trailing ifs can sometimes break this plugin. It looks like the problem only occurs when there are quotes before the if, eg:

class Foo

  def bar
    puts 'hello' if baz
  end

end

If you put the cursor on or after the 'if' keyword and press 'var' it works as expected. If you put the cursor on or before the word hello and press 'var', it's borked.

So I guess the problem is with your skip_pattern regexp. I tweaked it a bit to match any char (not just word chars) before the if, and that seems to do the trick.

Please review. And thanks for the excellent scotch!

@nelstrom
Copy link
Owner

Hey, thanks for the patch!

I thought that I had written tests for this type of scenario, but on closer inspection, I see that I marked the 'oneline conditionals' tests with TODO! I'll see if I can get those tests passing and merge in your patch.

@nelstrom
Copy link
Owner

This patch is still work in progress. I've updated the tests to include 'quotes' instead of :symbols, and changed the skip_pattern regex to be more permissive. The updated version works when I test manually, but the unit tests still fail. Not sure what's going on there, but I'd like to get them working.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants