Skip to content

Don't remove trailing newline when editing a file in web UI editor

Matthias Käppler requested to merge github/fork/jhund/fix-5936 into master

Created by: jhund

What does this MR do?

It addresses an issue where editing a file through the web UI (ACE editor) removes trailing newlines from the edited file.

The current implementation populates the ACE editor’s contents via the inner text of the pre#editor html tag. Since whitespace is not significant in HTML, any trailing newlines are lost when the ACE editor loads its contents from the HTML element. When the user saves the edits, the new file doesn’t have a trailing newline any more.

This commit changes how the editor’s content is populated to use the editor’s editor.setValue(); Javascript API method. Using the API preserves trailing newlines.

Why was this MR needed?

Because editing content via gitlab’s web UI should not strip the edited file’s trailing newlines.

What are the relevant issue numbers / Feature requests?

Merge request reports

Loading