Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion jupyter_server_documents/rooms/yroom_file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,17 @@ async def _load_content(self, jupyter_ydoc: YBaseDoc) -> None:
self.log.info(f"Processing outputs for loaded notebook: '{self.room_id}'.")
file_data = self.outputs_manager.process_loaded_notebook(file_id=self.file_id, file_data=file_data)

# Replace CRLF line terminators with LF line terminators
# Fixes #176, see issue description for more context.
content = file_data.get('content')
if isinstance(content, str) and '\r\n' in content:
self.log.warning(f"Detected CRLF line terminators in '{path}'.")
content = content.replace('\r\n', '\n')
self.log.info("Replaced CRLF line terminators with LF line terminators.")

# Set JupyterYDoc content and set `dirty = False` to hide the "unsaved
# changes" icon in the UI
jupyter_ydoc.source = file_data['content']
jupyter_ydoc.source = content
jupyter_ydoc.dirty = False

# Set `_last_modified` timestamp
Expand Down
Loading