forked from mia/Aegisub
Do a better job of picking a new active line after deleting lines
Set it to the first line not part of the selection after the selection begins if there are any, and the last line remaining in the file if not (i.e. the last line before the selection). Closes #1595.
This commit is contained in:
parent
71b14ecc74
commit
3c7527c2f7
1 changed files with 13 additions and 11 deletions
|
@ -470,23 +470,22 @@ static void copy_lines(agi::Context *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
||||||
AssDialogue *active = c->selectionController->GetActiveLine();
|
|
||||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||||
|
|
||||||
// Find a line near the active line not being deleted to make the new active line
|
// Find a line near the active line not being deleted to make the new active line
|
||||||
AssDialogue *new_active = 0;
|
AssDialogue *pre_sel = nullptr;
|
||||||
bool hit_active = false;
|
AssDialogue *post_sel = nullptr;
|
||||||
|
bool hit_selection = false;
|
||||||
|
|
||||||
for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) {
|
for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) {
|
||||||
if (diag == active) {
|
if (sel.count(diag))
|
||||||
hit_active = true;
|
hit_selection = true;
|
||||||
if (new_active) break;
|
else if (hit_selection && !post_sel) {
|
||||||
}
|
post_sel = diag;
|
||||||
|
break;
|
||||||
if (!sel.count(diag)) {
|
|
||||||
new_active = diag;
|
|
||||||
if (hit_active) break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
pre_sel = diag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete selected lines
|
// Delete selected lines
|
||||||
|
@ -494,6 +493,9 @@ static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
||||||
return sel.count(const_cast<AssDialogue *>(static_cast<const AssDialogue*>(&e)));
|
return sel.count(const_cast<AssDialogue *>(static_cast<const AssDialogue*>(&e)));
|
||||||
}, [](AssEntry *e) { delete e; });
|
}, [](AssEntry *e) { delete e; });
|
||||||
|
|
||||||
|
AssDialogue *new_active = post_sel;
|
||||||
|
if (!new_active)
|
||||||
|
new_active = pre_sel;
|
||||||
// If we didn't get a new active line then we just deleted all the dialogue
|
// If we didn't get a new active line then we just deleted all the dialogue
|
||||||
// lines, so make a new one
|
// lines, so make a new one
|
||||||
if (!new_active) {
|
if (!new_active) {
|
||||||
|
|
Loading…
Reference in a new issue