Skip to content

Incorrect saving of files with DOS line endings #448

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

Open
BaukJ opened this issue Mar 12, 2025 · 2 comments
Open

Incorrect saving of files with DOS line endings #448

BaukJ opened this issue Mar 12, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@BaukJ
Copy link

BaukJ commented Mar 12, 2025

Description

The collab plugin changes the autosave functionality to save files in a different route to normal jupyterlab file saves. This is not an issue without the collab plugin if manually saving or saving with the default autosave functionality.
When files have DOS line endings, any text entered is saved shifted to the left.
This is apparent if the file is closed and re-opened, as it appears fine in the editor but is saved incorrectly to disk.

The longer the file, the more shifted to the left, which makes it appear that the information sent through the websocket is ignoring the extra carriage return char, so when applying the changes to the file it does not take that into account, hence everything is shifted to the left.

Example of the same change being applied to 2 files, one with dos line endings and one with normal linux line endings:

==> example-dos.py <==

import os
import sys

nameKuba = ""
print(f"Hello {name}")

==> example-unix.py <==

import os
import sys

name = "Kuba"
print(f"Hello {name}")

Reproduce

See this PR with a failing test for DOS line endings with a carriage return and passing for Linux line endings without the carriage return: #449

Also see this notebook: https://github.com/BaukJ/work-snippets/blob/main/2025/03/sagemaker-dos-bug/DosBugNotebook.ipynb

And this video of the failing test, taken directly from the UI tests:
https://github.com/user-attachments/assets/49b539de-e857-451d-8816-58e00223c263

Expected behavior

Edits to files with DOS line endings should be correctly saved.

Context

Reproduced on multiple systems, first found in AWS sagemaker, but reproduced on vanilla jupyter and then got a failing test in the ui tests of this repo.
This does not happen when using jupyterlab's default save or autosave functionality.

@krassowski
Copy link
Member

Thank you. I do not have a good guess as to where the bug is coming from, but certainly having a test case should help with solving it.

@Hyrla
Copy link

Hyrla commented Apr 30, 2025

Hello, I can confirm that I have the same issue on my Jupyter Server. What could I provide to help you figure out this issue? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants