Sophrinix / TryRuby

Try Ruby is a interactive shell that quickly and whimsically teaches the Ruby programming language. Originally _why's idea, it has been recreated from the ground up by Rubyists who have a passion for Ruby and for teaching their fellow (wo)man how to program.
tryruby.org
345 stars 80 forks source link

Ends in strings #8

Closed ghost closed 14 years ago

ghost commented 14 years ago

For the auto-indentation feature, the nesting level will go down if you have things like "agenda".

ghost commented 14 years ago

thought of a solution (won't work with auto-indentation but worth it): instead of having a method to find the nesting level change, in run_script run the line (with previous lines) and check for an 'unexpected $end' error - if there was one, you know that the user needs to finish the statement. It will be like IRB.

davidmiani commented 14 years ago

This is odd, this bug doesn't occur in my version of tryruby, which is nearly the same as sophrinix's version. I thought this problem was a regression with the changes you have made. The current version uses a regexp like /^\s*end\s*$/ would match end but not "agenda"

I think the best plan would be to eventually replace the current code with using a persistent irb process, since atm every line of code sent to the server has to be run multiple times (which can't be very efficient CPU wise). This way we wouldn't have to lose auto indentation either.

ghost commented 14 years ago

I fixed the 'agenda' bug, but it will still match the end if it has spaces. You shouldn't use ^\send\s$ because you couldn't type "end.reverse" or "def asd; 'asd'; end". My version uses \b(end|})\b

ghost commented 14 years ago

you (whoever can figure out how to close this) should probably close it now, nanothief fixed it.

Sophrinix commented 14 years ago

Is the fix in orangea's repo, or just nanothief's?

ghost commented 14 years ago

it is in mine.

ghost commented 14 years ago

closing

ghost commented 14 years ago

... it didn't close. trying again.

ghost commented 14 years ago

unclosable!

Sophrinix commented 14 years ago

closed

Sophrinix commented 14 years ago

now