#6162 closed defect (fixed)
Trouble saving multiple changes when working with single-file packages
Reported by: | Philip Hannebohm | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | blocker | Milestone: | 1.17.0 |
Component: | OMEdit | Version: | |
Keywords: | Cc: | Francesco Casella |
Description
A student found this confusing behavior while working with a package in a single file.
Steps to reproduce:
- Open file
P.mo
in OMEdit - Open models
A
andB
in the tab-view - Edit both
- Save
A
- Observe that the change in
B
is lost
// P.mo package P model A // make some change here end A; model B // make some change here end B; end P;
I would expect the change in B
to remain in the editor. But It would already be less frustrating if OMEdit at least notifies the user that it is about to throw away unsaved changes from other tabs instead of silently reloading those other tabs. It's really not a problem once you get used to saving before you switch tabs, but it took us quite some time to identify and understand this behavior.
I'm aware that it could get difficult in cases where the contents of the two tabs "overlap", e.g. when the models are nested within each other like
model A //... model B //... end B; end A;
OMEdit would need to detect if the change in A
also affects B
. Could this be done by checking the line numbers of opened tabs/changed lines?
The ideal behavior, I think, would be:
- If the changes don't overlap, just save the change in
A
but keep the change inB
in the editor. - If the changes do overlap, tell the user that there is a "merge conflict" and ask which change to keep (possibly with a "don't ask me again, always do it like this" checkbox). A proper diff-tool might be overkill here.
Change History (6)
comment:1 by , 4 years ago
Milestone: | 2.0.0 → 1.17.0 |
---|---|
Priority: | high → blocker |
comment:4 by , 4 years ago
I checked with the latest nightly build. The behaviour with the first example (A
and B
defined at the same level) works fine.
The second example (B
defined within A
) is still a bit fishy. If I make some changes to B
in the window that only shows B
, actually even save them, and then switch to the windows containing A
, the version of B
that I see there is still the old one. Even if I close the tab A
and then reopen it, I still see the old B
code there. And of course if I now save the whole A
, the former "new" code of B
is unchanged.
This can extremely confusing, e.g., if you open an entire package defined in one file, and then happen to open some specific class of that package in a separate tab and use it for editing. One would expect that the overall package view is kept in sync, but it's not. Furthermore, two things are completely unclear:
- what is the status of the source code file on mass storage?
- what is the status of the package as loaded in memory?
I'm not sure how to deal with this, probably following @phannebohm's suggestion is a good starting point.
comment:5 by , 4 years ago
The second example (B defined within A) is still a bit fishy. If I make some changes to B in the window that only shows B, actually even save them, and then switch to the windows containing A, the version of B that I see there is still the old one. Even if I close the tab A and then reopen it, I still see the old B code there. And of course if I now save the whole A, the former "new" code of B is unchanged.
This works fine for me. This is what I did,
- Saved the example model to a file
A.mo
- Open the file in OMEdit.
- Opened the models
A
andA.B
- Updated the code in
A.B
- Switch to
A
comment:6 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I played with it a little and the new behavior is a pretty good solution.
I believe it does what one expects, except maybe that it also saves changes in other tabs, i.e. a tab is a small window into the file and when you edit/save you do it on the whole file. Once you think about it like this it makes perfect sense. And even unsaved changes get synchronized, so that helps to understand the behavior.
I can confirm comment:5 but not comment:4.
So I'm closing this ticket for now.
This is really critical, if you lose your work it's not nice.