{"record":{"id":"a46744d4553c9520","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-select-range-when-not-in-multi-select-mode","errorCode":null,"errorMessage":"Cannot select range when not in multi select mode.","messagePattern":"Cannot select range when not in multi select mode\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/ReorderableList.cs","lineNumber":670,"sourceCode":"        {\n            int insertionIndex = m_Selection.BinarySearch(index);\n            if (insertionIndex < 0 || append == false && m_Selection.Count > 1)\n            {\n                if (!append)\n                {\n                    m_Selection.Clear();\n                    m_Selection.Add(index);\n                }\n                else\n                {\n                    m_Selection.Insert(~insertionIndex, index);\n                }\n            }\n        }\n\n        public void SelectRange(int indexFrom, int indexTo)\n        {\n            if (!multiSelect) throw new InvalidOperationException(\"Cannot select range when not in multi select mode.\");\n\n            m_Selection.Clear();\n            for (int i = Mathf.Min(indexFrom, indexTo); i <= Mathf.Max(indexFrom, indexTo); ++i)\n            {\n                m_Selection.Add(i);\n            }\n        }\n\n        public bool IsSelected(int index)\n        {\n            return m_Selection.BinarySearch(index) >= 0;\n        }\n\n        public void Deselect(int index)\n        {\n            int foundIndex = m_Selection.BinarySearch(index);\n            if (foundIndex >= 0)\n            {","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/ReorderableList.cs#L652-L688","documentation":"ReorderableList.SelectRange throws InvalidOperationException when the list was not created with multiSelect=true. Range selection requires multi-select mode (it maintains an anchor and extends the selection set), so a single-select list cannot honor it and rejects the call.","triggerScenarios":"Calling list.SelectRange(from, to) on a ReorderableList constructed without multiSelect, or after multiSelect was set to false; a generic list helper that calls SelectRange without checking the mode.","commonSituations":"Reusing a list instance whose multiSelect flag changed; sharing a helper across single- and multi-select lists; default-constructed lists (multiSelect defaults false).","solutions":["Check list.multiSelect before calling SelectRange; fall back to single selection otherwise.","Construct the list with multiSelect: true if range selection is required.","Centralize selection logic in a helper that branches on multiSelect."],"exampleFix":"// before\nlist.SelectRange(from, to);\n// after\nif (list.multiSelect) list.SelectRange(from, to);\nelse list.index = from;","handlingStrategy":"validation","validationCode":"if (list.multiSelect)\n    list.SelectRange(indexFrom, indexTo);\nelse\n    list.index = indexFrom;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Gate SelectRange behind a multiSelect check.","Decide selection mode at construction and keep it stable.","Centralize selection logic in a helper that branches on multiSelect."],"tags":["imgui","reorderable-list","multiselect","invalid-operation","unity-editor"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}