I'm using Geany 1.33 on Windows 10 and invoke it from command line for an empty (zero byte) file. Though in the Geany preferences on the Files page the "Default end of line characters" combobox is set to "Windows (CRLF)", pressing enter and saving in the empty file will write Unix (LF) line endings.
What command do you use to invoke Geany from the command line?
Also, does it work as expected if you already have Geany open with some saved file open and then create a new file (ex. using `File->New`)?
I'm using following commands:
``` set file=foobar.txt
if not exist "%file%" ( type nul >> %file% )
start "" "C:\Program Files (x86)\Geany\bin\geany.exe" "%file%" ``` If I use `File->New` no empty file will be created, but one containing the configured line ending. Maybe that is the workaround ("hack") Geany actually is using to set the default.
The default applies only to new files created by Geany.
You are not creating a new file, you are opening an existing empty one. Since it has no line endings in it from which to determine the right one, the algorithm happens to end up on LF.
You need to either create the file with Geany and it uses the default as you confirmed, or write a blank line to your "empty" one so Geany can correctly determine its type.
I'd expect the default to be applied for **any case** where Geany could not detect the line endings from the file content. This bug is not only reproducible for empty files, but any files without line endings, e.g. one which only contains characters.
Sounds a useful enhancement, pull requests are welcome.
Why do you create the file at all? You can pass a file name to geany.exe and it will create a new one internally if it doesn't exist.
Hi this issue still exists on Windows 10 in Geany 1.38 (official Windows stable build).
My workflow is to create a new, 0-byte, file in a folder by right clicking an empty area and then clicking New -> [select file type]. When I do this Geany will consistently pick LF as the line ending type instead of my chosen default of CRLF. I've experienced weird issues in the past because of this due to me forgetting to manually change newly opened empty files to CRLF after opening them. I expect that this workflow is used by many other Geany users.
Geany should have the following behavior IMO:
If an opened file is zero bytes in length or it contains bytes but none of them are end of line characters, Geany should set the document line ending type to the value in: Preferences -> Files -> Default end of line characters
I'm not currently able to write a patch to create this behavior. I'd appreciate if someone else could do this.
@akima-io well, until "somebody" provides a pull request nothing is likely to happen, but since not many others seem to use your workflow it may not happen quickly.
The following is my workaround until Geany natively has this issue patched. I'm pasting it here for anyone who stumbles across this issue:
This workaround is because Geany uses **LF** line endings (not **CRLF**) for empty (0 byte) files. 0-byte files are what are ordinarily created when you create a new file via the Explorer context menu.
In `C:\Windows\ShellNew` I created these 5, identical, template files: ``` new_file.au3 new_file.bat new_file.py new_file.pyw new_file.txt ```
(you can obviously create your own set of files that you need for your setup)
Each file contains just one Windows newline (**CRLF**) and nothing else.
Next, using regedit run as Administrator, I did the following, once for each of those 5 files above:
(Substitute "EXT" below with the real template file extension:)
1. I created this key path (if it didn't already exist): HKEY_CLASSES_ROOT.EXT\ShellNew 2. At that path I created the "String" value: "FileName"="new_file.EXT" 3. If a value named "NullFile" pre-existed at the path I deleted it.
Now when I create a new file via the Explorer context menu and then open it with Geany, Geany will set the line endings to Windows, **CRLF** type.
github-comments@lists.geany.org