Text overrides restored file due to trailing newline
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 659
- Forks
- 133
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 110
Description
Describe the bug
Text auto saves unchanged file upon opening, no editing, due to a normalizer behavior. See videos:
To Reproduce
From the video, you need to restore a file and needs to have one specific thing, a trailing newline::
- restored version : 150 bytes, tail "...old line :)\n\n🌴\n"
- what Text wrote : 149 bytes, tail "...old line :)\n\n🌴"
- first difference at byte 149: restored "\n" vs written ""
Expected behavior
The serialiser should preserve a trailing newline, or SaveService should not write when the only difference is its own normalization. It's easy to demonstrate without Notes at all - put a markdown file ending in a newline in Files, open it in the Viewer, don't touch it, and a version appears within ~10 seconds.
Screenshots
https://github.com/user-attachments/assets/cdc53c60-243d-4400-994f-3647ead032f5
https://github.com/user-attachments/assets/9fbbed38-6bf2-4e17-afca-32a066ab50d1
Server details:
- Nextcloud version: master
- PHP Version: -
- Database: -
- I use the docker dev setup
Client details:
- OS: Win11pro
- Browser: FF
- Browser version: 153.0.4
- Device: Desktop
Logs
Nextcloud log (data/nextcloud.log)
Insert your Nextcloud log here
Browser log
Insert your browser log here, this could for example include:
a) The javascript console log
b) The network log
c) ...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SaveService and serializer path used by the Viewer, reproducing the issue with a markdown file whose content ends in a trailing newline. Done means opening an unchanged file no longer creates a new version, while serialization preserves the trailing newline.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100