Disable useless environment-split function at the core.

(cherry picked from commit f965d23633)
This commit is contained in:
Juergen Spitzmueller 2018-01-03 13:16:07 +01:00
parent 1b2dd66f78
commit d3ca12a5c2
2 changed files with 10 additions and 11 deletions

View File

@ -3232,7 +3232,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
break; break;
} }
else if (cur.paragraph().layout().isEnvironment()) { else if (cur.paragraph().layout().isEnvironment()) {
enable = true; enable = cmd.argument() == "before"
|| cur.pos() > 0 || !isFirstInSequence(cur.pit());
break; break;
} }
enable = false; enable = false;

View File

@ -1865,7 +1865,6 @@ void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv,
return; return;
pit_type pit = bv->cursor().selBegin().pit(); pit_type pit = bv->cursor().selBegin().pit();
pos_type pos = bv->cursor().selBegin().pos();
Paragraph const & par = text->getPar(pit); Paragraph const & par = text->getPar(pit);
docstring const curlayout = par.layout().name(); docstring const curlayout = par.layout().name();
docstring outerlayout; docstring outerlayout;
@ -1898,18 +1897,17 @@ void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv,
add(MenuItem(MenuItem::Command, toqstr(label), add(MenuItem(MenuItem::Command, toqstr(label),
FuncRequest(LFUN_ENVIRONMENT_SPLIT, FuncRequest(LFUN_ENVIRONMENT_SPLIT,
from_ascii("before")))); from_ascii("before"))));
if (!par.layout().keepempty || pos > 0 || !text->isFirstInSequence(pit)) { label = contextmenu ?
label = contextmenu ? bformat(_("Insert Separated %1$s Below"),
bformat(_("Insert Separated %1$s Below"), translateIfPossible(curlayout)):
translateIfPossible(curlayout)): bformat(_("Separated %1$s Below"),
bformat(_("Separated %1$s Below"), translateIfPossible(curlayout));
translateIfPossible(curlayout)); // We use command-alternatives here since this is how the binding is defined
// We use command-alternatives here since this is how the binding is defined // (otherwise, the binding is not displayed in the menu)
// (otherwise, the binding is not displayed in the menu) if (getStatus(FuncRequest(LFUN_ENVIRONMENT_SPLIT)).enabled())
add(MenuItem(MenuItem::Command, toqstr(label), add(MenuItem(MenuItem::Command, toqstr(label),
FuncRequest(LFUN_COMMAND_ALTERNATIVES, FuncRequest(LFUN_COMMAND_ALTERNATIVES,
from_ascii("environment-split ; environment-split previous")))); from_ascii("environment-split ; environment-split previous"))));
}
} }
else if (!prevlayout.empty()) { else if (!prevlayout.empty()) {
docstring const label = contextmenu ? docstring const label = contextmenu ?