8000 Fix double lines in CRLF EOL endings by sewbacca · Pull Request #45 · BigBahss/vscode-cmantic · GitHub
[go: up one dir, main page]

Skip to content

Fix double lines in CRLF EOL endings#45

Open
sewbacca wants to merge 2 commits intoBigBahss:masterfrom
sewbacca:master
Open

Fix double lines in CRLF EOL endings#45
sewbacca wants to merge 2 commits intoBigBahss:masterfrom
sewbacca:master

Conversation

@sewbacca
Copy link
@sewbacca sewbacca commented May 4, 2022

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).

@LeandroSQ
Copy link
LeandroSQ commented Feb 6, 2024

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?

@sewbacca
Copy link
Author
sewbacca commented Feb 7, 2024

Sure, I'd be happy to move it over. Just ping me the deeds, if you decided to fork the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0