diff --git a/ogl_editor/src/Commands.c b/ogl_editor/src/Commands.c index 3314d91..668fc2f 100644 --- a/ogl_editor/src/Commands.c +++ b/ogl_editor/src/Commands.c @@ -163,6 +163,7 @@ struct DeleteKeyData { int track; int row; + int noDelete; struct track_key oldKey; }; @@ -174,8 +175,11 @@ static void execDeleteKey(void* userData) struct sync_track* t = s_syncTracks[data->track]; int idx = sync_find_key(t, data->row); - if (idx == -1) + if (idx <= -1) + { + data->noDelete = 1; return; + } data->oldKey = t->keys[idx]; sync_del_key(t, data->row); @@ -189,6 +193,10 @@ static void undoDeleteKey(void* userData) { struct DeleteKeyData* data = (struct DeleteKeyData*)userData; struct sync_track* t = s_syncTracks[data->track]; + + if (data->noDelete) + return; + sync_set_key(t, &data->oldKey); RemoteConnection_sendSetKeyCommand(t->name, &data->oldKey); @@ -213,6 +221,7 @@ void Commands_deleteKey(int track, int row) command->undo = undoDeleteKey; data->track = track; data->row = row; + data->noDelete = 0; execCommand(command); } diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index 791e280..baf60b6 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -1177,6 +1177,8 @@ static void onMoveSelection(bool down) Commands_beginMulti("moveSelection"); + // Delete at the bottom as we are about to move the selection down otherwise in the top + for (track = selectLeft; track <= selectRight; ++track) { struct sync_track* t = tracks[track]; @@ -1188,10 +1190,12 @@ static void onMoveSelection(bool down) if (idx < 0) continue; + newKey = t->keys[idx]; newKey.row = down ? newKey.row + 1 : newKey.row - 1; - Commands_addOrUpdateKey(track, &newKey); + Commands_deleteKey(track, row); + Commands_addKey(track, &newKey); } }