cs-education / sysbuild

A system programming learning environment in the browser
https://cs-education.github.io/sys/
Other
36 stars 35 forks source link

Undo stack support with multiple files #163

Open coltonmercurio opened 8 years ago

coltonmercurio commented 8 years ago

Now that we can edit multiple files, we should retain a separate undo stack for each file that has been edited.

The Ace Editor EditSession provides methods to get and set the UndoManager

From this we could manage a mapping: file path --> current UndoManager within editor.js

When the current file is changed, save the current and load the new UndoManager into the EditSession Whenever a file's contents are manipulated via the VM or deleted, simply remove its UndoManager from the dictionary.

angrave commented 8 years ago

On 4/30/16 12:24 AM, Colton Mercurio wrote:

Now that we can edit multiple files, we should retain a separate undo stack for each file that has been edited.

The Ace Editor EditSession provides methods to get https://urldefense.proofpoint.com/v2/url?u=https-3A__ace.c9.io_api_edit-5Fsession.html-23EditSession.getUndoManager&d=CwMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=gSR9-bJGW_1_YlnNMRjF5T9K1667i2NtkJQf_X6_5JQ&s=LMz9kWXjqYfhTDNsTFyyCGC-noCuElKW7pmBqScbHzc&e= and set https://urldefense.proofpoint.com/v2/url?u=https-3A__ace.c9.io_api_edit-5Fsession.html-23EditSession.setUndoManager&d=CwMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=gSR9-bJGW_1_YlnNMRjF5T9K1667i2NtkJQf_X6_5JQ&s=g_yN-6XGdItg4E5fnpY4uZtl3i8nAUDjX_v28ItJLO0&e= the UndoManager https://urldefense.proofpoint.com/v2/url?u=https-3A__ace.c9.io_api_undomanager.html&d=CwMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=gSR9-bJGW_1_YlnNMRjF5T9K1667i2NtkJQf_X6_5JQ&s=ae8SGQTLg2ADbkr06R0Mg2dibUR3o_Ral3YhmmbujbM&e=

From this we could manage a mapping: file path --> current UndoManager within editor.js

When the current file is changed, save the current and load the new UndoManager into the EditSession Whenever a file's contents are manipulated via the VM or deleted, simply remove its UndoManager from the dictionary.

Some corner cases to consider-

And if a file is externally deleted?

And if a file is renamed to be the same as existing file (and then opened)

And if another file is renamed to be the one currently open in the editor

(there may be more - that's all that come to mind)

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_cs-2Deducation_sysbuild_issues_163&d=CwMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=gSR9-bJGW_1_YlnNMRjF5T9K1667i2NtkJQf_X6_5JQ&s=SPUxZpS-Xpw8IJi0hodSVASMFhnFUTThzq3t-t_dOeE&e=