Allow edit to select method based on index; print available methods in edit error message #39479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From #39476. cc @timholy
This PR adds the following:
edit(f::Function, method_idx::Integer)
that takes an array index formethods(foo).ms
as input.edit(f)
, and the function has >1 signatures, print outmethods(foo).ms
to the console, in addition to the normalERROR: function has multiple methods
.I think this gives a much quicker experience when trying to edit functions that have many signatures, making Revise.jl even smoother.
Here's an example workflow. Say I want to edit a method of function
foo
:Editor then opens method
foo(lt1::LongTypeName1, lt2::LongTypeName2; lt3::LongTypeName3)
, instead of needing to write out manuallyedit(methods(foo).ms[1])
or try to write out all the types. Andedit(foo)
printing the methods is nice, since then I don't need to printmethods(foo).ms
myself to check the signatures.The new error message for ambiguous
edit
on the functionless
looks like this:Then one can choose a method from this list, with, e.g.,
edit(less, 2)
, instead of having to: 1) print out all the methods withmethods(less)
, and 2) write out the tuple types or writeedit(methods(less).ms[2])
.