Author Topic: bug in "Settings->Editor->End-of-line options"  (Read 7687 times)

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
bug in "Settings->Editor->End-of-line options"
« on: June 09, 2010, 06:35:10 pm »
hi, everybody,

I'm not sure, but I think there is a bug in the mechanics of the "End-of-line mode" control. If a file is open and some change to that file is done and you don save the file, then change the EOL mode in the settings to another one, then change the EOL mode back to the former, all the EOL of that file are changed to that other mode.

Steps:
a) you start c::b with the EOL setting LF and edit a file
b) you change the EOL setting to CR
c) you change the EOL setting to LF
-> all EOL in the file are changed to CR

this seems to happen no matter what EOL mode the loaded file has, or even if it has mixed EOL's

So far the bug, if it really is one and not only a figment of my imagination  :)

And I have a question: is there any function inside of c::b to know what EOL mode an open file has? And: does it matter if a file isn't pure in it's EOL's? And: why does c::b respect the EOL's of a file when they are different from the systems EOL mode?

regards

frithjof 
« Last Edit: June 09, 2010, 06:38:56 pm by nausea »
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12597
    • Travis build status
Re: bug in "Settings->Editor->End-of-line options"
« Reply #1 on: June 09, 2010, 11:40:35 pm »
Turn off the "Ensure consistent EOL" option, if after that you get the same behavior, this is a bug
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: bug in "Settings->Editor->End-of-line options"
« Reply #2 on: June 10, 2010, 11:14:19 am »
the "Ensure consistent EOL" was not turned on. behavior as above.
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: bug in "Settings->Editor->End-of-line options"
« Reply #3 on: June 10, 2010, 11:42:55 am »
the "Ensure consistent EOL" was not turned on. behavior as above.
I can confirm this bug and will try to dig into it deeper.

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: bug in "Settings->Editor->End-of-line options"
« Reply #4 on: June 10, 2010, 04:57:40 pm »
there is another strange detail to the bug: if there are more than one files open the bug works as described. but aditionally if you switch to another file that file gets affected too: all EOL's are changed and the files status changes to "edited but not saved". this happens to all files you swich to and even with files that are opened now.

regards

frithjofh

PS: this bug doesn't seem very important. I actually stumbled over it by mistake  :?
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: bug in "Settings->Editor->End-of-line options"
« Reply #5 on: June 11, 2010, 11:11:22 am »
Should be (hopefully) be fixed in trunk (svn r6342).

I will explain the cause for it later (no time at the moment).

EDIT:
The error was caused by wxWidgets (or a misuse of checking or unchecking a wxMenuItem in a radiogroup).
The editorconfigurationdialog sets the eol-mode of the file to the new value.
If we reach MainFrame::OnEditMenuUpdateUI in main.cpp we set the appropriate menuitems accordingly.
The items are radio-items (only one can be checked) grouped in a submenu.
The former code tried to check and uncheck all items directly, but unchecking a checked radio-item causes a wxEVT_COMMAND_MENU_SELECTED and triggers MainFrame::OnEditEOLMode, which forces the change of the endofline-characters for the whole file.
We only need to check the MenuItem we want to have selected and leave the other untouched, because wxWidgets unchecks them itself.
By the way checking the item with the Check()-function does not trigger the event.

There is still a little inconsistency, if we check a menu-item via the Check()-function, we "only" change the default EOL-mode of the file and therfore all later typed EOL'S), but if we check it via the menu, we convert all EOL-characters in the file, even if "Ensure consisten EOLs" is not set.
« Last Edit: June 11, 2010, 11:42:58 am by jens »