Genio-The-Haiku-IDE / Genio

The Haiku IDE
Other
69 stars 8 forks source link

Unix line-endings assumed always #449

Closed SamuraiCrow closed 3 weeks ago

SamuraiCrow commented 3 weeks ago

On Genio v3.1, whenever I load a source code that uses Windows line endings, the editor switches it to Unix line-endings without asking. It is only detectable by the way that the document is marked immediately as being modified as soon as it is loaded.

jackburton79 commented 3 weeks ago

Does this happen with a specific project ? Do you have any public example I can try ?

nexus6-haiku commented 3 weeks ago

IIRC we now default to the Unix style unless instructed otherwise via .editorconfig. Try adding one to the root folder with the following lines:

# top-most EditorConfig file
root = true

# Windows-style newlines
[*]
end_of_line = crlf
#insert_final_newline = true
#indent_style = tab
#indent_size = 4

Uncomment the remaining lines as you wish

jackburton79 commented 3 weeks ago

Maybe se should detect the CR style instead, if no editorconfig is present?

SamuraiCrow commented 3 weeks ago

https://github.com/hitchhikr/protrekkr is a Windows repo with a Haiku makefile and uses conditional compilation. The line endings are cr/lf and when I open a file, it immediately changes the file. If I change it back to the proper line endings it still says the file has been changed. This will screw up the pull request if I submit it in that state. If you could sniff the first line ending used in the file and default to that, that would be preferred. Same for tabs/spaces in indentations.

SamuraiCrow commented 3 weeks ago

If .editorconfig could be generated from a dialog box instead of assuming wrong when setting up the git repo, that would be helpful. Maybe just having another tab in the project initialization would be another option to think about.

nexus6-haiku commented 3 weeks ago

Maybe se should detect the CR style instead, if no editorconfig is present?

Looking at the code, actually it does detect the line ending from the file and only if .editorconfig has end_of_line then it is forced to whatever it's there.

@SamuraiCrow did you try with the .editorconfig above? Does it work as intended?

nexus6-haiku commented 3 weeks ago

Please build Genio from source with the latest commit and let me know. I've tested it with your repo (protrekkr) and it seems fine now.

nexus6-haiku commented 3 weeks ago

@jackburton79 Genio should have behaved like this already. Now EndOfLineConvert() is not invoked if .editorconfig is not available. Nevertheless, I'll look into this more closely as soon as possible.

SamuraiCrow commented 3 weeks ago

Tested on 32 bit. It works on ToT (Tip of Tree).