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

Repl prepends whitespaces to wrapped lines causing issues with select+copy #205

Closed
nkvoll opened this Issue Aug 30, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@nkvoll

nkvoll commented Aug 30, 2015

The Repl prepends prompt.size whitespace characters to the beginning of new visual input lines (after soft wrapping). This makes it impossible (or dangerous) to copy using select + copy previous input from one shell to another because the contents may have changed depending on the terminal width and prompt size.

Consider this example: (using a short terminal width):

@ val foo = "lorem ipsum and the r
  est lorem ipsum and the rest lor
  em ipsum and the rest lorem ipsu
  m and the rest lorem ipsum and t
  he rest lorem ipsum and the rest
  "
foo: String = "lorem ipsum and the
 rest lorem ipsum and the rest lor
em ipsum and the rest lorem ipsum 
and the rest lorem ipsum and the r
est lorem ipsum and the rest"
@

Copying the first val (selecting everything from the first " to the last " from the input) results int he following string "lorem ipsum and the r est lorem ipsum and the rest lor em ipsum and the rest lorem ipsu m and the rest lorem ipsum and t he rest lorem ipsum and the rest " (notice the double-spaces added).

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Aug 30, 2015

Yep this is a problem. This is even worse for code, because the random spaces will probably break whatever snippet you were running and it won't even compile.

Here's a solution that I just found: Fish Shell does this pretty neat thing:

screenshot 2015-08-30 10 40 27

Where if your command takes more than one line, they kick it to the next line below the prompt and have it start from the far left. This preserves both the "normal" single-line experience, provides a properly-aligned multi-line experience, and allows correct C&P.

@lihaoyi lihaoyi changed the title from Repl prepends whitespaces to soft wrapped lines causing issues with select+copy to Repl prepends whitespaces to wrapped lines causing issues with select+copy Aug 30, 2015

@nkvoll

This comment has been minimized.

nkvoll commented Aug 31, 2015

That sounds like a sensible solution :)

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Nov 16, 2015

This continues to annoy me

@lihaoyi lihaoyi added the enhancement label Dec 1, 2015

@lihaoyi lihaoyi closed this in b91cb3d Feb 18, 2016

lihaoyi pushed a commit that referenced this issue Feb 18, 2016

Li Haoyi
Multi-line commands now format properly. We only "collapse" the margi…
…n to the left if there's individual rows that multi-line due to wrapping, and not when there's simple `\n`s in the buffer that results in short rows.

Given the problem statement of #205, this should solve it while still being relatively un-obtrusive in the common case where commands (even multi-line commands!) are short and do not wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment