Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with 'SIGINT' handling in LineEditor#reset #34

Merged
merged 1 commit into from
Jul 14, 2019

Conversation

luke-gru
Copy link
Contributor

@luke-gru luke-gru commented Jun 8, 2019

@old_trap is the string "DEFAULT" and not a callable object (Proc)
if there are no other signal handlers for SIGINT signal to chain.

Found running 'make test-all' running Ruby's test suite and CTRL-C'ing the terminal, resulted in NoMethodError 'call' on string "DEFAULT".

@old_trap is the string "DEFAULT" and not a callable object (Proc)
if there are no other signal handlers for SIGINT signal to chain.
@ghost
Copy link

ghost commented Jun 19, 2019

in 9d95ae8 ; the code-

def reset(prompt = '', encoding = Encoding.default_external)

    @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y

    @screen_size = Reline::IOGate.get_screen_size

    reset_variables(prompt, encoding)

    @old_trap = Signal.trap('SIGINT') {

      scroll_down(@highest_in_all - @first_line_started_from)

      Reline::IOGate.move_cursor_column(0)

      @old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT"

    }

  end
explaining the code

old_trap is a function or object.

old_trap.respond_to?(:call) means check if function of old_trap called respond_to does has attribute call. so old_trap has call.
->
@old_trap.respond_to?(:call) means check if function of old_trap called respond_to has instance variable call or is old_trap the instance variable?
->
@old_trap.call if @old_trap.respond_to?(:call) means execute old_trap.call if @old_trap.respond_to?(:call) evaluates to true.

and all this is inside the braces in @old_trap = Signal.trap('SIGINT') { ... } , so assigned to old_trap and that's what is used by other functions.


@luke-gru
Copy link
Contributor Author

@snow8gaia Sorry, I don't understand your comment.

@ghost
Copy link

ghost commented Jun 19, 2019

I don't fully understand how this pull request fixes this? Its great that it does.

For eg:-

Found running 'make test-all' running Ruby's test suite and CTRL-C'ing the terminal, resulted in NoMethodError 'call' on string "DEFAULT"

So, you ran make test-all in order to run Ruby's test-suite. Then pressed CTRL+C while in the terminal; that resulted in a NoMethodError call on string "DEFAULT".

@old_trap is the string "DEFAULT" and not a callable object (Proc)
if there are no other signal handlers for SIGINT signal to chain.

@old_trap is the string
its a string? is the string "DEFAULT" a valid signal that can be receive from the OS? why is old_trap calling a non-callable?

if there are no other signal handlers for SIGINT signal to chain.

so the SIGINT signal can't chain the functions. and the functions take strings as input.
other handler functions are absent, why?


Thanks anyways.

@ghost
Copy link

ghost commented Jun 19, 2019

ignore the timing of my earlier comment pull/34#issuecomment-503693550. Just read your response to issue/34#issuecomment-50368544; can't reply now.

@aycabta aycabta merged commit 3306677 into ruby:master Jul 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants