Hello!
This bug has annoyed me for years, so I decided to finally fix it. I
know, GRUB is GRUB Legacy now, but it there will be another release, it
should have this fix. Even if there will be no release, maybe this
patch will be applied by the OS vendors.
When using "e" to edit the commands followed by "b" to boot the edited
commands, the behavior of "savedefault" (if in was the command list)
seemed unpredictable. GRUB could suddenly select and boot a different
entry on the next boot.
As it turns out, "savedefault" was remembering the entry number in the
submenu used for editing the command. So, if e.g. the second command
was under the cursor, GRUB would default to the second entry on the next
boot. The fix is, of course, to calculate the current entry only in the
top level menu - either when booting or when calling a submenu.