Skip to content

[UI/autocomplete] tab-completion in scala REPL inserts TAB character on Mac OS X 10.6 #3990

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

Closed
scabug opened this issue Nov 10, 2010 · 6 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Nov 10, 2010

== Setup ==

Snow Leopard (10.6.4), !MacBookPro :

$$ uname -a
Darwin FOOBAR_OSX_HOST.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

Scala version
"2.8.0.final"

== Problem Description ==

  • In the Scala 'prompt'/interpreter, tab-completion (AKA autocomplete) is NOT working.
    [[BR]]

It simply inserts a TAB-character.

  • This behaviour is the same in both xterm (X11) and Terminal.app
    [[BR]]

  • I do not know whether this is a "core" Scala issue or a JLine problem.
    [[BR]]
    [[BR]]
    FWIW,
    [[BR]]
    in Terminal.app, Scala does not play well with readLine either: I have to use the rlwrap workaround.

[[BR]]

  • This makes repl-usage/-exploration difficult.
    [[BR]]

Especially in situations where it is required (per the repl's own guidelines!)

scala> :power
** Power User mode enabled - BEEP BOOP      **
** scala.tools.nsc._ has been imported      **
** New vals! Try repl, global, power        **
** New cmds! :help to discover them         **
** New defs! Type power.<tab> to reveal     **  <====== REPL is asking for TAB to "see more details" !!

In contrast,
[[BR]]

this works fine on a Linux host: hitting TAB offered me method-name completions as expected.
[[BR]]

== Examples ==

  • Below are attempts on[[BR]]

a. my !MacBookPro,

$$ scala
Welcome to Scala version 2.8.0.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> var a = "abc"
a: java.lang.String = abc

scala> a.<tab-character-inserted-here-when-I-hit-TAB>

[[BR]]

b. a linux M/C - scala built from trunk

$$ build/pack/bin/scala
Welcome to Scala version 2.9.0.r23460-b20101108003053 (Java HotSpot(TM) Client VM, Java 1.6.0_06).
Type in expressions to have them evaluated.
Type :help for more information.

scala> var a = "abc"
a: java.lang.String = abc

scala> a.<I-hit-TAB-here-and-saw-the-completions-offered-below>

+                     asInstanceOf          charAt
codePointAt           codePointBefore       codePointCount
compareTo             compareToIgnoreCase   concat
contains              contentEquals         endsWith
equalsIgnoreCase      getBytes              getChars
indexOf               intern                isEmpty
isInstanceOf          lastIndexOf           length
matches               offsetByCodePoints    regionMatches
replace               replaceAll            replaceFirst
split                 startsWith            subSequence
substring             toCharArray           toLowerCase
toString              toUpperCase           trim

scala> a.
$$ uname -a
Linux FOOBAR_LINUX_HOST 2.6.12-1.1372_FC3smp SI-1 SMP Fri Jul 15 01:30:03 EDT 2005 i686 i686 i386 GNU/Linux
  • Sought feedback on mailing-list[[BR]]

This was one of my initial-impressions that I was seeking community feedback from on the scala-users mailing-list: have already received very useful feedback on the other issues[[BR]]

[http://scala-programming-language.1934581.n4.nabble.com/Extremely-high-CPU-usage-no-Autocomplete-with-scala-2-8-0-final-Core2Duo-2-26GHz-2GB-MacBookPro-Mac--td3030894.html]

@scabug
Copy link
Author

scabug commented Nov 10, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3990?orig=1
Reporter: Livin Stephen Sharma (lss)
See #1

@scabug
Copy link
Author

scabug commented Nov 10, 2010

@paulp said:
It's something in your environment. I wrote all the completion code and I did it on osx; I've installed scala on at least a dozen different osx machines and tab completion always works. You haven't given enough information for me to tell why it doesn't work for you, but as I have no doubt it's specific to you I have to refer you to the mailing lists for help.

@scabug
Copy link
Author

scabug commented Nov 10, 2010

Livin Stephen Sharma (lss) said:
Yep, you're right about my environment being suspect here.

[[BR]]
I did this on my Mac:

mv ~/.bashrc ~/.bashrc.bak
sudo mv /etc/bashrc /etc/bashrc.bak

[[BR]]
Sure enough, completion works well after this (temporary) change.
[[BR]]

Thanks for taking a look!

@scabug
Copy link
Author

scabug commented Nov 10, 2010

@paulp said:
Replying to [comment:2 lss]:

[[BR]]
Sure enough, completion works well after this (temporary) change.
[[BR]]

Thanks for taking a look!

Sure. If you pinpoint the cause it'd be helpful if you noted it in a comment here for future problem havers.

@scabug
Copy link
Author

scabug commented Nov 10, 2010

Livin Stephen Sharma (lss) said:
Replying to [comment:3 extempore]:

Replying to [comment:2 lss]:

[[BR]]
Sure enough, completion works well after this (temporary) change.
[[BR]]

Thanks for taking a look!

Sure. If you pinpoint the cause it'd be helpful if you noted it in a comment here for future problem havers.
[[BR]]

In my .bashrc, I was setting a shell-variable "EMACS" to point to one of my emacs installations..
[[BR]]
[[BR]]

From man bash

       EMACS  If  bash  finds this variable in the environment when the shell starts with value "t", it assumes that the shell is running in
              an emacs shell buffer and disables line editing.

Simply using a less Powerful (!!) name for this variable 'fixes' the issue, and scala-completion works again.

@scabug scabug closed this as completed May 18, 2011
@scabug
Copy link
Author

scabug commented Apr 5, 2016

Aaron (redsymbol) said (edited on Apr 5, 2016 2:54:15 AM UTC):
To add to the knowledge base here:

I also experienced this lack of autocomplete on OS X 10.11.4, using Scala 2.11.7. I did not have EMACS set in my environment, but did have EDITOR exported to the value "vim". After exiting the scala REPL; running unset EDITOR; and then starting scala again, autocomplete on the repl appears to work perfectly.

I did not investigate whether setting to other values of $EDITOR made a difference, but it's interesting that my scala's autocompletion was hindered by an env variable that had nothing to do with emacs, either by name or value.

@scabug scabug added the repl label Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants