Trim trailing spaces in editor before saving the content
Discussed in here gitlab-com/www-gitlab-com!2717 (closed)
We should trim trailing spaces in the line end before posting editor content to server. The code below should do the trim.
session = aceEditor.getSession()
doc = session.getDocument()
lines = doc.getAllLines()
for lineContent, lineNumber in lines
trailingSpaceAt = lineContent.search /\s+$/
if trailingSpaceAt > -1
doc.removeInLine lineNumber, trailingSpaceAt, lineContent.length
finalContent = session.getValue()