When the file being parsed is open in the editor, ParseJob::readContents() uses KTextEditor::Document::text() to read the contents. At some point within KTextEditor, the line endings are normalized - even if the document uses \r or \r\n, the returned content is separated by \n only.
Otherwise, the contents are read directly from the file. Until this patch, the line endings aren't normalized in this case; the ParseJob contents differ depending on whether the file is open in the editor.
Several places in kdev-python assume that lines can be separated by, and end with, \n. Old-style Macintosh endings (\r) break this assumption, in the worst case causing a crash.
BUG: 378827
Using a regex in each instance would be a pain, and one code path normalizes line endings already, so I think the best option is to do so for background files also.
TODO: Enforce final newline?