Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#6162 closed defect (fixed)

Trouble saving multiple changes when working with single-file packages

Reported by: phannebohm Owned by: adeas31
Priority: blocker Milestone: 1.17.0
Component: OMEdit Version:
Keywords: Cc: casella

Description

A student found this confusing behavior while working with a package in a single file.

Steps to reproduce:

  1. Open file P.mo in OMEdit
  2. Open models A and B in the tab-view
  3. Edit both
  4. Save A
  5. 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 in B 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 Changed 3 years ago by casella

  • Milestone changed from 2.0.0 to 1.17.0
  • Priority changed from high to blocker

This is really critical, if you lose your work it's not nice.

comment:2 Changed 3 years ago by adeas31

comment:3 Changed 3 years ago by casella

Thank you Adeel!

We'll check that and report

comment:4 Changed 3 years ago by casella

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 Changed 3 years ago by adeas31

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 and A.B
  • Updated the code in A.B
  • Switch to A

comment:6 Changed 3 years ago by phannebohm

  • Resolution set to fixed
  • Status changed from new to 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.

Last edited 3 years ago by phannebohm (previous) (diff)
Note: See TracTickets for help on using tickets.