nixme / pry-nav

Binding navigation commands for Pry to make a simple debugger
MIT License
390 stars 35 forks source link

Assignment to 'c' is confused with abbreviated 'continue' command #3

Closed rparker closed 12 years ago

rparker commented 12 years ago

Innocent assignment to 'c' produces: Error: Cannot find local context. Did you use binding.pry?

For example: c = 2

rparker commented 12 years ago

Note that querying the value of 'c' is also a problem, so a fix that simply looks for a following assignment operator is not good enough...

nixme commented 12 years ago

Not sure if there's an easy fix. Perhaps I should just remove the aliases?

banister commented 12 years ago

@nixme @parker If there is demand to further disambiguate commands from ruby code we can do a couple of things:

(1) Show a warning when collisions occur (2) Support an optional mode toggle for a command mode and a code mode (so no conflicts can occur)

Any of these appeal to either of you? any other suggestions?

nixme commented 12 years ago

Both sound like possible solutions.

Just thinking out loud, but what about two modes: the current one where commands and code are intermixed, and one where only commands work. Short aliases, like 'c', would only be enabled in command-only mode where they'd have more utility.

rparker commented 12 years ago

Dual modes, like 'vi', seems like too much of a change.

I'd be happy just to get a warning about the variable-name / command collision... The problem right now is that the error message does not lead you to an understanding of the problem.

nixme commented 12 years ago

Got it. I can improve the error messaging in the next release.

ConradIrwin commented 12 years ago

This has been reported as a bug in pry (again): https://github.com/pry/pry/issues/492

We've got an experimental feature that warns the user when this happens, but a better fix is to not destroy the single-letter namespace by default (from my own experience that's the kind of variable name that I use most often while in a REPL).

lucapette commented 12 years ago

I was just going to report the issue in pry too. A search brought me here.

@ConradIrwin is right IMHO. It's very common to use single letters in a REPL for variables. Probably, you should consider removing them. Or is there a way to override the alias with the variables and just show a warning message? But that can be annoying anyway... What do you think?

nixme commented 12 years ago

Aliases removed in version 0.2.0 (released yesterday).

A note added to the README about adding aliases to ~/.pryrc

lucapette commented 12 years ago

Thank you very much!