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 source and browse utilities to be able to use out of the box #1284

Merged
merged 2 commits into from
Aug 25, 2022

Conversation

tanishiking
Copy link
Contributor

fix #1254

This PR enables Ammonite-REPL to use browse and source built-in utilities out of the box.

ammonite-browse

  • browse
  • source
    • define browseSourceCommand that is called from macro (looks like forgotten to port in ba57f10)
    • Added repl.codeColorsImplicit to predefImport, (is this ok?)
    • Add pprint.PPrinter as default parameters (in a wired way)
      • default argument doesn't work for macro definition
      • import implicit pprint.PPrinter to REPL scope may change the behavior of other commands (like grep, browse) because they also receive implicit pprint.PPrinter (but it would be better to use different printer instance?)

Copy link
Collaborator

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

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

Nice!

I wonder if we don't miss some implicit PPrinter somewhere… These used to work fine IIRC. I might have messed with the implicit PPrinter instance that should have been implicitly available in the session. But that can always be fixed later I guess.

@alexarchambault alexarchambault merged commit cd76521 into com-lihaoyi:master Aug 25, 2022
@scalway
Copy link
Contributor

scalway commented Sep 15, 2022

EDIT: Yea... It is already merged and I missed that for some reason :).

None of this versions works in my system (intel/ubuntu 22.04.1 LTS):

$ scala-cli repl --ammonite-version 2.4.0 --ammonite --scala 2.13.5
...
$ scala-cli repl --ammonite-version 2.5.1 --ammonite --scala 2.13.7
...
$ scala-cli repl --ammonite-version 2.5.4 --ammonite --scala 2.13.8
Welcome to the Ammonite Repl 2.5.4 (Scala 2.13.8 Java 11.0.16)
@ source(scala.collection.mutable.Buffer) 
cmd0.sc:1: could not find implicit value for parameter pprinter: pprint.PPrinter
val res0 = source(scala.collection.mutable.Buffer)
                 ^
Compilation Failed

This works like expected:

~$ scala-cli repl --ammonite-version 2.3.8 --ammonite --scala 2.13.5
Welcome to the Ammonite Repl 2.3.8 (Scala 2.13.3 Java 11.0.16)
@ source(scala.collection.mutable.Buffer)
//shows it as expected

And this also works:

~$ scala-cli repl --ammonite-version 2.5.4-26-9cd15abe --ammonite --scala 2.13.8
Welcome to the Ammonite Repl 2.3.8 (Scala 2.13.3 Java 11.0.16)
@ source(scala.collection.mutable.Buffer)
//shows it as expected

btw: It is pleasure to use scala-cli in such cases :).

@tanishiking
Copy link
Contributor Author

This change isn't included in 2.5.4, will be available in the next release (or the latest build as you tested 👍)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

source and browse utilities broken out of the box by no PPrinter
3 participants