Le 10/07/2022 à 15:23, Kornel Benko a écrit :
Like this? Feel free to make it simpler.
Rather like this. Note that your patch did not avoid duplicates on the command list available from the up arrow icon. There are indeed two lists that are more or less kept in sync. What a mess.
What do you think? It does not remove duplicates in the whole list, but I believe that this is how it should work.
JMarc
From e9682fa5834ac3196cb7f109737ce1b6cc2e40db Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Sun, 10 Jul 2022 18:03:52 +0200 Subject: [PATCH] Avoid duplicate commands in command buffer history The situation of this code is weird because one has to update both the history_ of GuiCommandBuffer and the lastcommands vector of Sessio stuff. One of these should go eventually. --- src/frontends/qt/GuiCommandBuffer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt/GuiCommandBuffer.cpp b/src/frontends/qt/GuiCommandBuffer.cpp index 956821c23e..05ecd86886 100644 --- a/src/frontends/qt/GuiCommandBuffer.cpp +++ b/src/frontends/qt/GuiCommandBuffer.cpp @@ -159,8 +159,6 @@ GuiCommandBuffer::GuiCommandBuffer(GuiView * view) void GuiCommandBuffer::dispatch() { std::string const cmd = fromqstr(edit_->text()); - if (!cmd.empty()) - theSession().lastCommands().add(cmd); DispatchResult const & dr = dispatch(cmd); if (!dr.error()) { view_->setFocus(); @@ -345,7 +343,11 @@ DispatchResult const & GuiCommandBuffer::dispatch(string const & str) return empty_dr; } - history_.push_back(trim(str)); + string const hist_str = trim(str); + if (hist_str != history_.back()) { + history_.push_back(hist_str); + theSession().lastCommands().add(hist_str); + } history_pos_ = history_.end(); upPB->setEnabled(history_pos_ != history_.begin()); downPB->setEnabled(history_pos_ != history_.end()); -- 2.34.1
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel