From 572d0c083f87138c05fd05acd8bd4340cc4e43ed Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 23 Jun 2017 06:46:34 +0000 Subject: [PATCH] TabBar: Fixed issues with context menu with no highlighted item git-svn-id: svn://ultimatepp.org/upp/trunk@11194 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/TabBar/TabBar.cpp | 11 ++++++----- uppsrc/ide/Navigator.cpp | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/uppsrc/TabBar/TabBar.cpp b/uppsrc/TabBar/TabBar.cpp index dc5cb4f26..17b836125 100644 --- a/uppsrc/TabBar/TabBar.cpp +++ b/uppsrc/TabBar/TabBar.cpp @@ -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); diff --git a/uppsrc/ide/Navigator.cpp b/uppsrc/ide/Navigator.cpp index 747b88cfb..90cc0928c 100644 --- a/uppsrc/ide/Navigator.cpp +++ b/uppsrc/ide/Navigator.cpp @@ -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& 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;