Skip to content

Loading…

New Method command doens't work properly #59

Closed
jacob-carlborg opened this Issue · 10 comments

2 participants

@jacob-carlborg

There are a couple of issues with the New Method command.

  1. Doesn't work for class methods. Typing self.foo and invoke the command results in:

    self.def foo (args)
    
    end
  2. The command behaves strangely when removing (args) and then starts typing. Steps to reproduce:

    1. Type "foo"
    2. Invoke the command
    3. Press backspace to remove (args)
    4. Type "bar"

    The result is this:

    def foo   ((ar))r)) 
    end

    And there are now three cursors.

  3. The command doesn't work if a method ends with ? or !. Typing foo! and invoking the command results in this:

    foodef !(args)
    
    end
@jacob-carlborg

All of these problems where present in TM1 as well, except for the second one.

@infininight
textmate member

The second issue is unfortunate but just a symptom of how the snippet is formed and not easily fixable. Since you can type the whole method name before invoking the command it shouldn't happen too often.

One and three I've got a fix worked up for, going to test it a bit more to make sure there aren't any issues. Should have it committed tomorrow.

@jacob-carlborg

It happens to me all the time because of the third issue. But if that's being fixed it will be less of an issue.

@infininight infininight added a commit that closed this issue
@infininight infininight Allow all forms of method names in New Method (⇧↩)
Before we just used the current word which doesn't match all possible method names (self.foo or foo! for instance). Now uses the current_word library to allow any possible method name with the expression taken from the grammar. Fixes #59.
da63813
@infininight
textmate member

Just deployed this change, your bundle should update in a few hours.

Please test out this change with any issues that you had as I totally rewrote the logic in the command, thanks!

@jacob-carlborg

It works, thanks. Although, I forgot about one case, when a method ends with =.

@infininight
textmate member

Can you provide an example of this usage? I used the match from the grammar so it should have caught everything the grammar does.

@jacob-carlborg

Type foo= then invoke the action. This is the result:

def foo(args)

end
@jacob-carlborg

I don't know if this helps but. When I type foo= the equal sign is highlighted, but the neither the question mark or the exclamation mark gets highlighted. Perhaps the grammar is treating them differently.

@infininight infininight added a commit that referenced this issue
@infininight infininight Allow for method names that end in =
Further fixes #59.
50782f8
@infininight
textmate member

@jacob-carlborg The fix I just made should fix the lingering issue.

@jacob-carlborg

Great, thanks :smiley:.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.