TabBar: Fixed issues with context menu with no highlighted item

git-svn-id: svn://ultimatepp.org/upp/trunk@11194 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-06-23 06:46:34 +00:00
parent 1e8c5d717f
commit 572d0c083f
2 changed files with 8 additions and 6 deletions

View file

@ -453,17 +453,16 @@ int TabBar::GetNextId()
void TabBar::ContextMenu(Bar& bar)
{
if (GetCursor() >= 0 && crosses) {
bar.Add(tabs.GetCount() > mintabcount, t_("Close"), THISBACK2(Close, highlight, true));
}
int ii = GetHighlight(); // Need copy to freeze it, [=] copies 'this' and thus reference to highlight
if (GetCursor() >= 0 && crosses && ii >= 0)
bar.Add(tabs.GetCount() > mintabcount, t_("Close"), THISBACK2(Close, highlight, true));
if (ii >= 0 && crosses)
bar.Add(t_("Close others"), [=] { CloseAll(ii); });
if (ii < GetCount() - 1 && crosses)
if (ii >= 0 && ii < GetCount() - 1 && crosses)
bar.Add(t_("Close right tabs"), [=] { CloseAll(-1, ii + 1); });
if (mintabcount <= 0 && crosses)
bar.Add(t_("Close all"), [=] { CloseAll(-1); });
if(grouping) {
if(grouping && ii >= 0) {
if(group > 0)
bar.Add(t_("Close group"), THISBACK(CloseGroup));
bar.Separator();
@ -2482,6 +2481,8 @@ void TabBar::SetTabGroup(int n, const String &group)
void TabBar::CloseForce(int n, bool action)
{
if(n < 0 || n >= tabs.GetCount())
return;
if(n == active)
{
int c = FindId(tabs[n].id);

View file

@ -512,12 +512,13 @@ void Navigator::Search()
else
if(IsNull(s) && !sorting) {
const CppBase& b = CodeBase();
bool sch = GetFileExt(theide->editfile) == ".sch";
for(int i = 0; i < b.GetCount(); i++) {
String nest = b.GetKey(i);
const Array<CppItem>& ci = b[i];
for(int j = 0; j < ci.GetCount(); j++) {
const CppItem& m = ci[j];
if(m.file == fileii) {
if(m.file == fileii && (!sch || !m.IsData() || m.type != "SqlId")) {
NavItem& n = nitem.Add();
n.Set(m);
n.nest = nest;