[LyX/master] Remove handling of dispatched() property in BufferView::dispatch

Jean-Marc Lasgouttes lasgouttes at lyx.org
Fri Sep 6 14:24:03 UTC 2024


commit e5c31699b4d8fd13c71212158d835c7fa750100f
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Fri Sep 6 16:21:47 2024 +0200

    Remove handling of dispatched() property in BufferView::dispatch
    
    As indicated in DispatchResult.h, this is only needed in insets'
    doDispatch() methods, where lfuns can be delegated to a higher lever.
---
 src/BufferView.cpp | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 665f4673d5..b1ac2da82c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1450,8 +1450,6 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 	    && lyxaction.funcHasFlag(cmd.action(), LyXAction::NoInternal))
 		return;
 
-	// We'll set this back to false if need be.
-	bool dispatched = true;
 	buffer_.undo().beginUndoGroup();
 
 	FuncCode const act = cmd.action();
@@ -1638,8 +1636,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 			InsetMathRef * minset =
 				getInsetByCode<InsetMathRef>(cur, MATH_REF_CODE);
 			if (minset)
-				lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO,
-							minset->getTarget()));
+				lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, minset->getTarget()));
 		}
 		break;
 	}
@@ -1898,14 +1895,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 		FindAndReplaceOptions opt;
 		istringstream iss(to_utf8(cmd.argument()));
 		iss >> opt;
-		if (findAdv(this, opt)) {
+		if (findAdv(this, opt))
 			dr.screenUpdate(Update::Force | Update::FitCursor);
-			cur.dispatched();
-			dispatched = true;
-		} else {
-			cur.undispatched();
-			dispatched = false;
-		}
 		break;
 	}
 
@@ -2199,10 +2190,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 				how = SCROLL_TOGGLE;
 			else if (where == "visible")
 				how = SCROLL_VISIBLE;
-			else {
-				dispatched = false;
+			else
 				break;
-			}
 			showCursor(how);
 			break;
 		}
@@ -2212,10 +2201,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 			scroll_step = d->scrollbarParameters_.single_step;
 		else if (scroll_type == "page")
 			scroll_step = d->scrollbarParameters_.page_step;
-		else {
-			dispatched = false;
+		else
 			break;
-		}
 
 		string const scroll_quantity = cmd.getArg(1);
 
@@ -2225,10 +2212,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 			scroll(scroll_step);
 		else if (isStrInt(scroll_quantity))
 			scroll(scroll_step * convert<int>(scroll_quantity));
-		else {
-			dispatched = false;
+		else
 			break;
-		}
 
 		dr.screenUpdate(Update::ForceDraw);
 		dr.forceBufferUpdate();
@@ -2478,14 +2463,13 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 				if (!opt1.empty())
 					LYXERR0("Discarding optional argument to citation-insert.");
 			}
-			dispatched = true;
 			break;
 		}
 		InsetCommandParams icp(CITE_CODE);
 		icp["key"] = from_utf8(arg);
 		if (!opt1.empty())
 			icp["before"] = from_utf8(opt1);
-		icp["literal"] = 
+		icp["literal"] =
 			from_ascii(InsetCitation::last_literal ? "true" : "false");
 		string icstr = InsetCommand::params2string(icp);
 		FuncRequest fr(LFUN_INSET_INSERT, icstr);
@@ -2571,7 +2555,6 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 		if (cur.inTexted() && cur.selection()
 		    && cur.selectionBegin().idx() != cur.selectionEnd().idx()) {
 			buffer_.dispatch(cmd, dr);
-			dispatched = dr.dispatched();
 			break;
 		}
 		cap::copySelection(cur);
@@ -2581,12 +2564,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 	default:
 		// OK, so try the Buffer itself...
 		buffer_.dispatch(cmd, dr);
-		dispatched = dr.dispatched();
 		break;
 	}
 
 	buffer_.undo().endUndoGroup();
-	dr.dispatched(dispatched);
 
 	// NOTE: The code below is copied from Cursor::dispatch. If you
 	// need to modify this, please update the other one too.


More information about the lyx-cvs mailing list