Skip to content

End of line / EOL #1447

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
vivek-verma202 opened this issue Apr 26, 2020 · 16 comments · May be fixed by vivek-verma202/GWAS_FM#2
Closed

End of line / EOL #1447

vivek-verma202 opened this issue Apr 26, 2020 · 16 comments · May be fixed by vivek-verma202/GWAS_FM#2
Labels
meta: 🤔 reporter-feedback-needed cannot process further since we need more info from the reporter

Comments

@vivek-verma202
Copy link

vivek-verma202 commented Apr 26, 2020

The bug

I am not sure if this issue traces back to Theia. The IDE adds extra line breaks.

The behavior

when I copy (cntrl + c) and paste in my Ubuntu terminal, the output looks:

for i in {1..22}; do

cat -> test_${i} << EOF

#!/bin/bash

echo ${i}

EOF

done

Expected behavior

for i in {1..22}; do
cat -> test_${i} << EOF
#!/bin/bash
echo ${i}
EOF
done

Additional information

tried fixing it manually (with no luck):
"files.eol": "\n"

@jankeromnes
Copy link
Contributor

jankeromnes commented Apr 27, 2020

Hi @vivek-verma202, are you copying text from a Theia editor and pasting them in an Ubuntu Terminal, or the other way around? (Or what are copying from where to where?)

Maybe it could be helpful if you provide a screenshot or screencast demonstrating the problem.

@jankeromnes jankeromnes added the meta: 🤔 reporter-feedback-needed cannot process further since we need more info from the reporter label Apr 27, 2020
@Kreyren
Copy link

Kreyren commented Apr 27, 2020

kreyren is infuriated by the bash used and can't resist not commenting on it

fwiw double-quote the variables to avoid word-splitting, don't use echo since it's non-standard on XNU, useless use of cat and surrounding variables in curly brackets is bloat, use shellcheck https://github.com/koalaman/shellcheck so the correct version would look like:

for int in {1..22}; do
<<-EOF > "test_$int"
    #!/usr/bin/env bash
    printf '%s\n' "$int"
EOF
done

kreyren runs away, because it's off-topic

@vivek-verma202
Copy link
Author

the script:

for i in {1..5}; do
echo ${i}
done
Look on the gitpod editor (no extra spaces):
code_edit

Look on the gitpod editor's terminal (again, no extra spaces):
t1

And, when I copy - paste to Ubuntu terminal:
Screenshot from 2020-04-27 14-52-30
(These extra EOLs is not an issue, unless in case of scripts which expect first line to be shebang.)

@Kreyren
Copy link

Kreyren commented Apr 27, 2020

FWIW i don't have this issue on my end:
image

Caused by an extension?

Something relevant to ubuntu terminal?

@Kreyren
Copy link

Kreyren commented Apr 27, 2020

Is this gitpod on windows parsing the content to WSL ubuntu terminal? (Windows is placing garbage on new-line that usually cause this behaviour)

Relevant: https://github.com/koalaman/shellcheck/wiki/SC1017

@vivek-verma202
Copy link
Author

I am using Google chrome on Ubuntu machine.
Copying and pasting on gedit shows no anomalous line break behavior.

Copying lines from Gitpod -> text editor (Gedit) -> Ubuntu 20 / CentOS 7 terminal: again, no anomalous line line breaks.

I have asked Gitpod explicitly to use \n as EOL. But I do notice a small "!" on my settings.json file. Is something wrong with it?

Screenshot

@Kreyren
Copy link

Kreyren commented Apr 28, 2020

@vivek-verma202

Copying and pasting on gedit shows no anomalous line break behavior.

Afaik gedit won't show these since it's formatting the text, can you copy paste these in http://dpaste.com/ ? (or any other way to get raw to us like github's gists https://gist.github.com/)

I have asked Gitpod explicitly to use \n as EOL. But I do notice a small "!" on my settings.json file. Is something wrong with it?

  1. editor.cursorWidth is invalid, because you are parsing string to property that expects integer, see
    image

recommends removing double-quotes " from value -> So correct syntax is
"editor.cursorWidth": 2,

  1. There also seems to be other issues that i can't reproduce on my system, try hovering over theses underscored properties to see what is wrong:
    image

Note that gitpod is linting settings.json so you can see all the problems in:
image

  1. If that did not help then try to make a backup of your current settings.json and see if the issue persist, if not try to figure out which property is causing this behavior and report it to us. :)

  2. If changing the settings.json did not help, then provide me list of extensions used. You can find these in .gitpod.yml (for repository-wide) or in GUI for user+repository extensions:
    image

@svenefftinge
Copy link
Member

FWIW I also cannot reproduce this on my mac using chrome. I tried with auto and \n settings for files.eol.
The warnings (!) you see in your settings are indicating that you have specified the same value twice. You should remove one. But really this is unrelated.

@vivek-verma202
Copy link
Author

Thank-you so much guys! I was able to fix silly issues in my settings.json and get rid of the annoying "!".

Copy paste from Gitpod to http://dpaste.com/ did not show extra line breaks.
Its not terminal settings, bash_profile or .bashrc issue as copy-paste from gedit or http://dpaste.com/ works absolutely fine.

My "version"of Gitpod / Theia is doing something non-fatal but non-trivial with eols. This is not a generic Gitpod / Theia issue as I was not able to reproduce it when I copy-pasted from: https://ec77d690-8322-4dd1-8052-e70cfe28fd72.ws-us02.gitpod.io/#/workspace/spring-petclinic

Hence, there seems to be something specific with the docker image that I am using. How can I fix it? I need no special functionality (just vanilla sh).

Thanks again.

@Kreyren
Copy link

Kreyren commented Apr 28, 2020

Copy paste from Gitpod to http://dpaste.com/ did not show extra line breaks.

If it's in the raw it won't show up on browser's view of dpaste (browsers do not render these by default) where i was expecting the dpaste link alike http://dpaste.com/0QGE4X4 which looks like this on dpaste:
image

So that i could pipe it in vim with :set lists shows the special characters:
image

or in editor capable of rendering invisibles like gitpod (see https://stackoverflow.com/a/61355603 if you want to know how):
image

My "version"of Gitpod / Theia is doing something non-fatal but non-trivial with eols. This is not a generic Gitpod / Theia issue as I was not able to reproduce it when I copy-pasted from:

kreyren still suspect this being relevant to cascadian return on Windows/DOS

Can you share your:

  1. your used browser? (Ideally user-agent from http://whatsmyuseragent.org/)
  2. used kernel? (i.e Windows, MacOS, Linux, Redox!, FreeBSD, etc..)
  3. your repository or is it private? assuming private since i can't find it on your profile

https://ec77d690-8322-4dd1-8052-e70cfe28fd72.ws-us02.gitpod.io/#/workspace/spring-petclinic

image

@vivek-verma202
Copy link
Author

The dpaste link: http://dpaste.com/3V6Z4SB

Gitpod is not allowing me to use:

"code-eol.newlineCharacter": "¬",
"code-eol.returnCharacter" : "¤",
"code-eol.crlfCharacter"   : "¤¬"

I have made the following workspaces public:

  1. gitpod-io/spring-petclinic - master (which adds no extra eols i.e. copy-paste works as expected, got it from "try in Gitpod" on https://theia-ide.org/)

  2. vivek-verma202/GWAS_FM - master (which adds extra eols)

I am using Google chrome, Version 81.0.4044.129 (Official Build) (64-bit).

User agent:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36

Linux Kernel:

tried it on two (same problem):

  1. Linux version 3.10.0-1062.12.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) "integrated chat" on status bar non functional #1 SMP Tue Feb 4 23:02:59 UTC 2020

  2. Linux version 5.4.0-26-generic (buildd@lcy01-amd64-029) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) Support Elixir language #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020

Kreyren pushed a commit to Kreyren/GWAS_FM that referenced this issue Apr 28, 2020
Attempts-to-resolve: gitpod-io/gitpod#1447

Signed-off-by: Jacob Hrbek < kreyren@member.fsf.org>
@Kreyren
Copy link

Kreyren commented Apr 28, 2020

The dpaste link: http://dpaste.com/3V6Z4SB

Interesting! i see what i assume is unexpected ¤¬ which is on my gitpod character for CRLF (carriage-return) which is what i believe is causing this issue

image

But this is usually specific to Windows/DOS (never seen this on linux in 14 years) so i find it unexpected that this behavior has been observed on linux which is using 0x0D character instead of standard new-line 0x0A

‘\n’ == ASCII 10 == 0x0A == line feed

‘\r’ == ASCII 13 == 0x0D == carriage return

Based on available informations my best guess would be that this is caused by some extension that is not optimized for usage on Linux.
Can you try to disable all extensions and if that fixed the issue and if so try to figure out which extension is causing this.

If this solves the issue i recommend filing a new issue to extension developer (that is likely the responsible for this behavior assuming that we can't reproduce it and available info above) informing them about this behavior.


Looking at the provided repository (https://github.com/vivek-verma202/GWAS_FM):

  • Repository is not using any repository-wide extension that i can see
  • The whole code is using unexpected carriage-return characters instead of new-line:
    image
  • I can reproduce the carriage-return on provided repository in master.bash
    • I can't reproduce the behavior in new file -> Assuming that this is copy-pasted bash file that has been originally written on Windows/DOS and gitpod is using the already present carriage return instead of expected new-line
  • Created MR Replace carriage return with blank vivek-verma202/GWAS_FM#2, please verify if you still have this issue

@Kreyren
Copy link

Kreyren commented Apr 28, 2020

Gitpod is not allowing me to use:

Also as referenced on https://stackoverflow.com/a/61355603
image

you need this extension https://marketplace.visualstudio.com/items?itemName=medo64.render-crlf for gitpod to recognize these properties

@Kreyren
Copy link

Kreyren commented Apr 28, 2020

Also note https://www.gitpod.io/docs/languages/bash/ for shell-relevant development on gitpod

@vivek-verma202
Copy link
Author

Got it!!
Fixed the option "CRLF" to "LF" on the lower right panel:
Screenshot

Thank you so much for your help!
Gitpod's a pretty awesome concept. Keep up the hard work..

@Kreyren
Copy link

Kreyren commented Apr 29, 2020

kreyren forgot that option is there x.x

@vivek-verma202 also a solution! :p but you should consider using shellcheck anyway it prevents lots of problems ^-^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta: 🤔 reporter-feedback-needed cannot process further since we need more info from the reporter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants