nextcloud / files_texteditor

:page_facing_up: Text editor for plaintext files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Editing converts line endings to CR LF

wolframroesler opened this issue · comments

Summary

Editing a .md file in the markdown editor automatically converts all line ending to Windows style (CR LF), even if the file is using Unix-style (LF only) line endings. Instead, the editor should analyze the file to find out which style it's using, create new lines with that style, and leave everything else unchanged.

To understand why the present behaviour is a problem, put a big Unix-style .md file into a git repo, put the repo into your Nextcloud, edit the file with the markdown editor, and then do "git diff".

(I originally reported this to the files_markdown repo (icewind1991/files_markdown#125). Was told it belongs here instead.)

Steps to reproduce

  1. Create a text file with Unix line endings (LF only) in your Nextcloud.
  2. Open the file in the app.
  3. Insert a single character.
  4. Wait until the app auto-saves the file.

Expected behaviour

The line endings in the file should still be LF only.

Actual behaviour

All line endings are converted to Windows style (CR LF).

Server configuration

Operating system:
Lubuntu

Web server:
nginx

Database:
MariaDB

PHP version:
Don't know but I don't think it matters

Nextcloud version: (see Nextcloud admin page)
15

Where did you install Nextcloud from:
Internet

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder

Nextcloud configuration:

If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your Nextcloud installation folder

or

Insert your config.php content here
Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …)

Client configuration

Browser:
Vivaldi, Chromium, Safari

Operating system:
macOS, Linux

Logs

Nextcloud log (data/owncloud.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) ...

I have the same problem. The editor saves files always with CR LF, no matter which OS the browser runs on or what the file looked like before editing. So I cant use it for most of my use cases.

commented

+1

commented

I think, the problem lies in editor.js line 448 "aceEditor.getSession().setNewLineMode("windows");"

Yes, but it has to be fixed by the devs. The line you mentioned should be removed or set to auto. Hopefully the devs unddrestand that saving all files with windows line endings is a bug and a problem for most people.

I tried changing the file per the above (c/windows/auto) but it did not change the behavior of the editor. Is there anything else I need to do to make it take effect? (I tried disabling and enabling the app to no avail).

Maybe remove cache and/or do a Shift-reload in the browser? I'm guessing the scripts are cached.