Skip to content

Feature: Using ctrl-C  #33

@jwoertink

Description

@jwoertink

When using IRB, if you're writing out multi-line code, and you make a typo, you can use ctrl-C to sort of reset you back to normal. Take this for example:

[14:07PM] crystal-icr (bugs/alias)$ irb
2.3.1 :001 > class Dog
2.3.1 :002?>   def bark
2.3.1 :003?>     ebd
2.3.1 :004?>     ^C
2.3.1 :004 > 1 + 1
 => 2 
2.3.1 :005 > puts "back to normal"
back to normal
 => nil 

With ICR currently, if you hit ctrl-C, then it will completely exits the session back to your main prompt. If you've been spending time building out an example, then you will have lost setting up variables and such.

Since this needs to work a bit different than how IRB works, my plan would be to create some sort of status that knows if the current state is ok or not. Then catching Signal::INT would basically clear everything back to the last good state.

If you like the idea, then I'll work on sending a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions