gitlabhq/gitlabhq — pull request #7222 by jhund (2014-06-27 17:57:12+00:00)
Title: Don't remove trailing newline when editing a file in web UI editor

### 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?

* #5936
* This fix makes the workaround in [`gitlabhq/app/controllers/projects/edit_tree_controller.rb#preview`](https://github.com/gitlabhq/gitlabhq/blob/master/app/controllers/projects/edit_tree_controller.rb#L31) obsolete.