RangeSelect/MultiSelect: Fix testing key mods from after the nav request (remove need to hold the mod longer)
diff --git a/imgui_internal.h b/imgui_internal.h
index a77a7f5..9d8923b 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1255,6 +1255,7 @@
     bool                    MultiSelectEnabled;
     ImGuiMultiSelectFlags   MultiSelectFlags;
     ImGuiMultiSelectState   MultiSelectState;                   // We currently don't support recursing/stacking multi-select
+    ImGuiKeyModFlags        MultiSelectKeyMods;
 
     // Render
     ImDrawData              DrawData;                           // Main ImDrawData instance to pass render information to the user
@@ -1430,6 +1431,7 @@
 
         MultiSelectEnabled = false;
         MultiSelectFlags = ImGuiMultiSelectFlags_None;
+        MultiSelectKeyMods = ImGuiKeyModFlags_None;
 
         DimBgRatio = 0.0f;
         BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index dd91328..71af120 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -5906,6 +5906,9 @@
     g.MultiSelectEnabled = true;
     g.MultiSelectFlags = flags;
 
+    // Use copy of keyboard mods at the time of the request, otherwise we would requires mods to be held for an extra frame.
+    g.MultiSelectKeyMods = g.NavJustMovedToId ? g.NavJustMovedToKeyMods : g.IO.KeyMods;
+
     if ((flags & ImGuiMultiSelectFlags_NoMultiSelect) == 0)
     {
         state->In.RangeSrc = state->Out.RangeSrc = range_ref;
@@ -5916,9 +5919,9 @@
     // FIXME: Polling key mods after the fact (frame following the move request) is incorrect, but latching it would requires non-trivial change in MultiSelectItemFooter()
     if (g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == state->FocusScopeId && g.NavJustMovedToHasSelectionData)
     {
-        if (g.IO.KeyShift)
+        if (g.MultiSelectKeyMods & ImGuiKeyModFlags_Shift)
             state->InRequestSetRangeNav = true;
-        if (!g.IO.KeyCtrl && !g.IO.KeyShift)
+        if ((g.MultiSelectKeyMods & (ImGuiKeyModFlags_Ctrl | ImGuiKeyModFlags_Shift)) == 0)
             state->In.RequestClear = true;
     }
 
@@ -6002,13 +6005,13 @@
     if (state->InRequestSetRangeNav)
     {
         IM_ASSERT(id != 0);
-        IM_ASSERT(g.IO.KeyShift);
+        IM_ASSERT((g.MultiSelectKeyMods & ImGuiKeyModFlags_Shift) != 0);
         const bool is_range_dst = !state->InRangeDstPassedBy && g.NavJustMovedToId == id;     // Assume that g.NavJustMovedToId is not clipped.
         if (is_range_dst)
             state->InRangeDstPassedBy = true;
         if (is_range_src || is_range_dst || state->In.RangeSrcPassedBy != state->InRangeDstPassedBy)
             selected = state->In.RangeValue;
-        else if (!g.IO.KeyCtrl)
+        else if ((g.MultiSelectKeyMods & ImGuiKeyModFlags_Ctrl) == 0)
             selected = false;
     }
 
@@ -6026,9 +6029,9 @@
 
     bool selected = *p_selected;
     bool pressed = *p_pressed;
-    bool is_ctrl = g.IO.KeyCtrl;
-    bool is_shift = g.IO.KeyShift;
     const bool is_multiselect = (g.MultiSelectFlags & ImGuiMultiSelectFlags_NoMultiSelect) == 0;
+    bool is_ctrl = (g.MultiSelectKeyMods & ImGuiKeyModFlags_Ctrl) != 0;
+    bool is_shift = (g.MultiSelectKeyMods & ImGuiKeyModFlags_Shift) != 0;
 
     // Auto-select as you navigate a list
     if (g.NavJustMovedToId == id)