From 21d881908306022a5926db72ccd5c5fcc717063c Mon Sep 17 00:00:00 2001 From: John T Maxwell III Date: Wed, 25 Sep 2024 13:19:40 -0700 Subject: [PATCH] Fix LT-20588: Crash in Affix Process Rule (#167) --- Src/LexText/Morphology/AffixRuleFormulaControl.cs | 2 +- Src/LexText/Morphology/RuleFormulaControl.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/LexText/Morphology/AffixRuleFormulaControl.cs b/Src/LexText/Morphology/AffixRuleFormulaControl.cs index d4a714094c..d26af2de80 100644 --- a/Src/LexText/Morphology/AffixRuleFormulaControl.cs +++ b/Src/LexText/Morphology/AffixRuleFormulaControl.cs @@ -176,7 +176,7 @@ private bool DisplayVariableOption(object option) private bool DisplayColumnOption(object option) { SelectionHelper sel = SelectionHelper.Create(m_view); - if (sel.IsRange) + if (sel == null || sel.IsRange) return false; int cellId = GetCell(sel); diff --git a/Src/LexText/Morphology/RuleFormulaControl.cs b/Src/LexText/Morphology/RuleFormulaControl.cs index 0d4bc323dd..ab8c40fc3b 100644 --- a/Src/LexText/Morphology/RuleFormulaControl.cs +++ b/Src/LexText/Morphology/RuleFormulaControl.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2015 SIL International +// Copyright (c) 2015 SIL International // This software is licensed under the LGPL, version 2.1 or later // (http://www.gnu.org/licenses/lgpl-2.1.html) @@ -569,6 +569,12 @@ private void m_insertionControl_Insert(object sender, InsertEventArgs e) var redo = string.Format(MEStrings.ksRuleRedoInsert, option); SelectionHelper sel = SelectionHelper.Create(m_view); + if (sel == null) + { + // The selection can become invalid because of an undo (see LT-20588). + m_insertionControl.UpdateOptionsDisplay(); + return; + } int cellId = -1; int cellIndex = -1; switch (option.Type)