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 Ctrl+Q for stack traces #36344

Merged
merged 9 commits into from
Jul 8, 2020
Merged

Fix Ctrl+Q for stack traces #36344

merged 9 commits into from
Jul 8, 2020

Conversation

simeonschaub
Copy link
Member

@simeonschaub simeonschaub commented Jun 18, 2020

This should be a more general fix than #36341. It currently silently gets stuck while generating precompile statements on my machine, but not sure if that's reproducible.

close #36340

@tkf
Copy link
Member

tkf commented Jun 18, 2020

Maybe try debug_output = stdout?

debug_output = devnull # or stdout

stdlib/REPL/src/REPL.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/REPL.jl Outdated Show resolved Hide resolved
@simeonschaub simeonschaub force-pushed the fix_36272_2 branch 2 times, most recently from a07d52b to ffd4fb3 Compare June 18, 2020 16:49
@simeonschaub
Copy link
Member Author

@tkf What do you think should be done about the helpmode case? The relevant code is in docview.jl, but the problem is that io is not passed through as an argument and some of those functions are documented, so I don't know if we can just easily change them.

@tkf
Copy link
Member

tkf commented Jun 18, 2020

I guess we need #34949 to fix help mode? This PR as-is is still a big usability improvement/fix so I think we should just merge this.

Do you think it's possible to write a few tests for this?

@simeonschaub
Copy link
Member Author

It's probably possible to write a test here, but I'm not really familiar with how REPLTests.fake_repl works, so I would appreciate any pointers from people who have written those existing REPL tests. Last time I looked into it, I didn't get very far.

@tkf tkf added display and printing Aesthetics and correctness of printed representations of objects. REPL Julia's REPL (Read Eval Print Loop) labels Jun 18, 2020
@tkf
Copy link
Member

tkf commented Jun 18, 2020

I think it'd be easier to unit-test this than doing an integration test. It's a bit cumbersome to setup a REPL instance, though:

julia> term = REPL.TTYTerminal("dumb",IOBuffer(),IOBuffer(),IOBuffer());

julia> repl = REPL.LineEditREPL(term, false);

julia> repl.specialdisplay = REPL.REPLDisplay(repl);

julia> REPL.print_response(repl, (:hello, false), true, false)

julia> String(take!(term.out_stream))
":hello\n"

@simeonschaub
Copy link
Member Author

I guess we need #34949 to fix help mode? This PR as-is is still a big usability improvement/fix so I think we should just merge this.

#36289 doesn't really buy us a lot here, because methods actually gets called in e.g. Docs.@doc Base._in, which in turn calls REPL.lookup_doc, so fixing this would mean having to change how parts of the Docs module work.

@tkf
Copy link
Member

tkf commented Jun 19, 2020

Ah, I see. So Docs.@doc macro creates a string before it is printed again. Yeah, it sounds like a non-trivial problem.

Copy link
Member

@tkf tkf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to set IOContext outside outstream. This function sounds like an accessor function and having a side-effect is not great. For example, it'd mean some innocent use like

println(outstream(repl))

would clear out last_shown_line_infos. I think it'd be cleaner if we can keep outstream as a simple accessor. We've already discussed this in #36344 (comment) but do you think the change I suggested here work? It's just moving what we were doing in display to print_response.

stdlib/REPL/src/REPL.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/REPL.jl Outdated Show resolved Hide resolved
stdlib/REPL/src/REPL.jl Outdated Show resolved Hide resolved
@tkf tkf added the needs tests Unit tests are required for this change label Jun 19, 2020
@tkf tkf changed the title alternative fix for #36340 Fix Ctrl+Q for stack traces Jun 19, 2020
@KristofferC KristofferC added this to the 1.6 milestone Jun 24, 2020
@KristofferC
Copy link
Member

Bump.

Copy link
Member Author

@simeonschaub simeonschaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my laptop crashed, that's why it took me some time to restore the changes I made. I refactored most of the logic behind the hint message into with_methodtable_hint to avoid duplicating this code. I also realized that LAST_SHOWN_LINE_INFOS should probably be lowercase now, since it's no longer a global variable.

@@ -110,7 +110,7 @@ end

let s = "using REP"
c, r = test_complete(s)
@test count(isequal("REPL"), c) == 1
@test count(isequal("REPL"), c) == 2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue what's going on here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, this now breaks the CI test, but was needed locally on my machine for tests to pass 🤔.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, this now breaks the CI test, but was needed locally on my machine for tests to pass

Yeah, it's a bug in the REPL tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does CI run the tests with different options or why isn't this bug present there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#32377 has some more info.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the pointer!

base/methodshow.jl Outdated Show resolved Hide resolved
@staticfloat
Copy link
Member

Just a note that this is somehow freezing up the buildbots :(

@simeonschaub
Copy link
Member Author

Are they actually frozen? To me, it looked like they finished, but somehow didn't report back correctly to GitHub. Might have been because GitHub was down for a while?

@tkf
Copy link
Member

tkf commented Jul 1, 2020

Yeah it looks like the problem is on GitHub side. For example, tester_linux64 is finished but package_linux64 still says it's pending.

@staticfloat
Copy link
Member

Are they actually frozen? To me, it looked like they finished, but somehow didn't report back correctly to GitHub.

Yes they're freezing, I go in manually and end them. Here's one that was been running for 21 hours before I killed it: https://build.julialang.org/#/builders/77/builds/1247

@simeonschaub
Copy link
Member Author

Do you think that's related to this PR? That's kind of the annoying thing about changing something in REPL – You change some small thing and suddenly some other thing gets silently broken/stuck. 😄

@staticfloat
Copy link
Member

Yes, it's been consistent with this PR, unfortunately. Here's another one: https://build.julialang.org/#/builders/77/builds/1281

That being said, the latest version of this seems to have made it through the package_* builders for win64, so maybe you fixed it? I'm only seeing it on Windows, perhaps there's something particularly weird about that platform's handling of this?

@simeonschaub
Copy link
Member Author

Weird... I don't see how any of these changes could have fixed this.

@simeonschaub
Copy link
Member Author

I've rebased onto the latest master, let's hope the Windows build still goes through. 😁

@simeonschaub
Copy link
Member Author

@staticfloat All tests now passed, so it seems like this should be ok now. @tkf Would you be willing to review?

Copy link
Member

@tkf tkf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -495,6 +484,22 @@ function complete_line(c::LatexCompletions, s)
return unique!(map(completion_text, ret)), partial[range], should_complete
end

with_methodtable_hint(f, repl) = f(outstream(repl))
function with_methodtable_hint(f, repl::LineEditREPL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think this is a clean approach!

@tkf
Copy link
Member

tkf commented Jul 3, 2020

@KristofferC Do you want to review it again?

If no objections, let's merge this in a few days.

@simeonschaub
Copy link
Member Author

Bump.

@tkf tkf merged commit 114e581 into JuliaLang:master Jul 8, 2020
@tkf
Copy link
Member

tkf commented Jul 8, 2020

Thanks for the fix! (and the ping)

simeonschaub added a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
* alternative fix for JuliaLang#36340
* refactor method hint mechanism
* make LAST_SHOWN_LINE_INFOS lowercase
* implement style suggestion from @KristofferC
* fix use of LAST_SHOWN_LINE_INFOS on latest master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. needs tests Unit tests are required for this change REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ctrl+Q stopped working for stack traces etc.
4 participants