X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FSession.cpp;h=d79a5a09a94a8874c699e312d89321e0f5acf156;hb=7261fa94482916cb9bf2ba0d21c4df390ea58320;hp=16b6df7c61b2a3bca93cce9fb73dc85a256f3eba;hpb=42b23f3fb24ea38e2b40543f4822a62d492e305a;p=lyx.git diff --git a/src/Session.cpp b/src/Session.cpp index 16b6df7c61..d79a5a09a9 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -353,6 +353,15 @@ BookmarksSection::bookmarksInPar(FileName const & fn, int const par_id) const } +void BookmarksSection::adjustPosAfterPos(FileName const & fn, + int const par_id, pos_type pos, int offset) +{ + for (Bookmark & bkm : bookmarks) + if (bkm.filename == fn && bkm.top_id == par_id && bkm.top_pos > pos) + bkm.top_pos += offset; +} + + LastCommandsSection::LastCommandsSection(unsigned int num) : default_num_last_commands(30), absolute_max_last_commands(100) @@ -399,6 +408,11 @@ void LastCommandsSection::setNumberOfLastCommands(unsigned int no) void LastCommandsSection::add(std::string const & command) { + // remove traces of 'command' in history using the erase-remove idiom + // https://en.wikipedia.org/wiki/Erase%E2%80%93remove_idiom + lastcommands.erase(remove(lastcommands.begin(), lastcommands.end(), command), + lastcommands.end()); + // add it at the end of the list. lastcommands.push_back(command); }