SebastianBecker2 / PowerPlanSwitcher

Tray-Icon tool to show the currently selected windows power plan, switch it manually and automatically.
MIT License
33 stars 4 forks source link

Problems with line breaks in "PowerSchemeSelectorDlg.Designer.cs". #23

Closed wuguo138428 closed 3 months ago

wuguo138428 commented 3 months ago

Synchronizing from your master branch, there is always a problem with line breaks in the "PowerSchemeSelectorDlg.Designer.cs" file, the problem should not be with me! I'm just starting to work on your code and I'm getting this popup. You said this problem, I corrected it in 1.0.7.0, synchronization 1.1.0.0 started to pop up this window again! 屏幕截图 2024-06-27 163655 屏幕截图 2024-06-27 163804

SebastianBecker2 commented 3 months ago

Yeah, you're right. The main branch is, or any branch for that matter, screwed up.

I shouldn't have merged that PR with the broken line endings. I thought it would fix itself. I expected git to push the files with LF. But the logic seems way more confusing. Most works as I expect. Files are converted to CRLF (for Windows) when they are pulled. But they are not pushed with LF to the remote. Git pushes only changes. And it acquires the changes by comparing the current file on disk with the pulled file (after conversion to CRLF). So it won't fix itself. At least that is my current understanding.

You can try for yourself by pulling the LineEndingCheck branch. It's from the 70cc916 commit. The commit before I merged your first PR. Regardless of how your git client converts line endings, it should be consistent over the whole repo. All source files NEED to have the same line ending. Probably CRLF considering your git client will convert those accordingly. To get the original line endings like they are on the github server, you can manually download the branch as a zip file. To do so, select the LineEndingCheck branch on github, click the green <>Code button and select Download ZIP: image When you unpack the file and open them in notepad++, you will see them all with LF line ending.

Another problem I ran into face first was Visual Studio Code. Which I used to verify the line endings. But I didn't know that Visual Studio Code "fixes" line endings of a file when opening it. So I didn't see the actual line endings of the file and I wasn't aware of that. It's a nice feature if it could be deactivated. But apparently Microsoft thinks this feature should always be on.

Regardless... before doing anything else, I will fix this issue. I'm not sure how though. Most of the time when fixing the line ending and trying to commit the change, the commit fails because the change is gone.

Thank your for insisting on this. And the screenshot of Notepad++. I haven't used Notepad++ for years. But once again, it's the absolute most reliable editor. And the only one I can trust with freaking line endings.

SebastianBecker2 commented 3 months ago

I think I fixed the line ending issue in the main branch. I converted all affected files to LF, checked them in and pushed them. I verified by downloading the ZIP and checking the line endings again. They are all LF on the server. When cloning the repo and checking out the branch, everything is CRLF. Which should be correct. At least for my system.

I will have to merge the main branch into your branches. This will update the PRs.

Now I have to do that for another, local branch of mine. I will have to be more careful in the future.