vscode-cmantic
vscode-cmantic copied to clipboard
Fix double lines in CRLF EOL endings
I noticed a strange bug when using CRLF line endings. Whenever i wanted to add a definition, somehow an excess of newlines would appear, e.g.:
void Instance::function()
{
}
Which seemed strange, at first and after a little digging, I found the issue:
Whenever you add tabspaces to a block, you appear to use insertText.replace(/^/gm, util.indentation())
to prepend any indentation. Unfortunatly it does work only with LF line endings. When using CRLF line endings, it assumes the \r
and \n
are both line seperators (instead of completly\r\n
), which led to inserting tabspaces between and after them, resulting in \r\t\n\t
. Then, vscode would translate these into \r\n\t\r\n\t
(or at least in an equivalent visual representation).
To fix the issue, I have created a function in utilities
, called insertBeforeEachLine
, which solves the issue and I have replaced each occurence $1.replace(/^/gm, $2)
with util.insertBeforeEachLine($1, $2)
.
I have another change ready to go:
- Support for creating source file when adding definition and file does not exist
- Support for multiple editors when revealing source code, reusing instead of opening new editor
But it seems this repo is not maintained anymore, I'm considering forking it and maintaining myself. Would you be willing to move your PR there if that would be the case?
Sure, I'd be happy to move it over. Just ping me the deeds, if you decided to fork the repository.