Fixed for move selection

This commit is contained in:
Daniel Collin 2014-09-22 21:54:41 +02:00
parent 36391d5cb0
commit 256258c058
2 changed files with 15 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);
}
}