Wiki editor trims leading and trailing whitespace, breaking formatting
Summary
When editing a wiki page, the first line's leading whitespace and the last line's trailing whitespace is (unexpectedly) trimmed, which sometimes breaks Markdown formatting.
Steps to reproduce
- Go to a project's Wiki section and click "New page"
- Enter this content:
- item 1 - item 2
- Click "Create page"
- It correctly creates a page with 2 items at the same indentation level — good
- Click the Edit button
- The Content field now shows this: — bad
- item 1 - item 2
- Without changing anything, click "Save changes"
- The wiki page now shows the 2 items at different indentation levels — bad
- Click "Page history" and click the "Changes" link for the most recent change
- The changes page shows that the leading spaces on the first line have been removed, and that the linebreak following the second line has been removed — bad
Example Project
What is the current bug behavior?
The first line's leading whitespace and the last line's trailing whitespace is trimmed.
What is the expected correct behavior?
If I click Edit then click "Save changes" without changing anything, the wiki text should remain exactly the same (the diff should be empty).
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com and on my self-hosted instance.