diff --git a/Src/Common/Controls/Widgets/FwComboBox.cs b/Src/Common/Controls/Widgets/FwComboBox.cs index e27beed32b..2d50b6ec9e 100644 --- a/Src/Common/Controls/Widgets/FwComboBox.cs +++ b/Src/Common/Controls/Widgets/FwComboBox.cs @@ -1069,8 +1069,8 @@ protected void ShowDropDownBox() } else { - //m_comboListBox.FormWidth = this.Size.Width; - sz.Width = Width; + // If the programmer set an explicit width for the list box, that width is stored in DropDownWidth. + sz.Width = DropDownWidth; } if (sz != m_dropDownBox.Form.Size) diff --git a/Src/Common/Controls/Widgets/PopupTree.cs b/Src/Common/Controls/Widgets/PopupTree.cs index 3372056dc3..f39d04cb54 100644 --- a/Src/Common/Controls/Widgets/PopupTree.cs +++ b/Src/Common/Controls/Widgets/PopupTree.cs @@ -293,7 +293,7 @@ protected override Size DefaultSize { get { - return new Size(300, 600); + return new Size(300, 400); // Previously, used (120, 200) for the default size. // Width set to 120 lets the popuptree dropdown match the width of the box that it drops down from, // but this doesn't allow enough space to view trees that contain several layers. diff --git a/Src/LexText/LexTextControls/MSAGroupBox.cs b/Src/LexText/LexTextControls/MSAGroupBox.cs index fdf8510652..49445e0570 100644 --- a/Src/LexText/LexTextControls/MSAGroupBox.cs +++ b/Src/LexText/LexTextControls/MSAGroupBox.cs @@ -625,7 +625,6 @@ private void InitializeComponent() // this.m_fwcbAffixTypes.AdjustStringHeight = true; this.m_fwcbAffixTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.m_fwcbAffixTypes.DropDownWidth = 140; this.m_fwcbAffixTypes.DroppedDown = false; resources.ApplyResources(this.m_fwcbAffixTypes, "m_fwcbAffixTypes"); this.m_fwcbAffixTypes.Name = "m_fwcbAffixTypes"; @@ -642,7 +641,8 @@ private void InitializeComponent() // m_tcMainPOS // this.m_tcMainPOS.AdjustStringHeight = true; - this.m_tcMainPOS.DropDownWidth = 140; + // Setting width to match the default width used by popuptree + this.m_tcMainPOS.DropDownWidth = 300; this.m_tcMainPOS.DroppedDown = false; resources.ApplyResources(this.m_tcMainPOS, "m_tcMainPOS"); this.m_tcMainPOS.Name = "m_tcMainPOS"; diff --git a/Src/LexText/ParserCore/FwXmlTraceManager.cs b/Src/LexText/ParserCore/FwXmlTraceManager.cs index 79a9fe45f2..9fa8155d33 100644 --- a/Src/LexText/ParserCore/FwXmlTraceManager.cs +++ b/Src/LexText/ParserCore/FwXmlTraceManager.cs @@ -10,6 +10,9 @@ using SIL.Machine.Morphology.HermitCrab.MorphologicalRules; using SIL.Machine.Morphology.HermitCrab.PhonologicalRules; using SIL.Machine.FeatureModel; +using SIL.Machine.Annotations; +using System.Collections.Generic; +using System.Text; namespace SIL.FieldWorks.WordWorks.Parser { @@ -129,16 +132,18 @@ public void PhonologicalRuleApplied(IPhonologicalRule rule, int subruleIndex, Wo { ((XElement) output.CurrentTrace).Add(new XElement("PhonologicalRuleSynthesisTrace", CreateHCRuleElement("PhonologicalRule", rule), - CreateWordElement("Input", input, false), - CreateWordElement("Output", output, false))); + // Show bracketed to make debugging phonological rules easier (fixes LT-18682). + CreateWordElement("Input", input, false, true), + CreateWordElement("Output", output, false, true))); } public void PhonologicalRuleNotApplied(IPhonologicalRule rule, int subruleIndex, Word input, FailureReason reason, object failureObj) { var pruleTrace = new XElement("PhonologicalRuleSynthesisTrace", CreateHCRuleElement("PhonologicalRule", rule), - CreateWordElement("Input", input, false), - CreateWordElement("Output", input, false)); + // Show bracketed to make debugging phonological rules easier (fixes LT-18682). + CreateWordElement("Input", input, false, true), + CreateWordElement("Output", input, false, true)); var rewriteRule = rule as RewriteRule; if (rewriteRule != null) @@ -386,16 +391,36 @@ private static XElement CreateInflFeaturesElement(string name, FeatureStruct fs) return new XElement(name, fs.Head().ToString().Replace(",", "")); } - private static XElement CreateWordElement(string name, Word word, bool analysis) + private static XElement CreateWordElement(string name, Word word, bool analysis, bool bracketed = false) { string wordStr; if (word == null) wordStr = "*None*"; else - wordStr = analysis ? word.Shape.ToRegexString(word.Stratum.CharacterDefinitionTable, true) : word.Shape.ToString(word.Stratum.CharacterDefinitionTable, true); + wordStr = analysis + ? word.Shape.ToRegexString(word.Stratum.CharacterDefinitionTable, true) + : bracketed ? ToBracketedString(word.Shape, word.Stratum.CharacterDefinitionTable) + : word.Shape.ToString(word.Stratum.CharacterDefinitionTable, true); return new XElement(name, wordStr); } + private static string ToBracketedString(IEnumerable nodes, CharacterDefinitionTable table) + { + StringBuilder stringBuilder = new StringBuilder(); + foreach (ShapeNode node in nodes) + { + string text = table.GetMatchingStrReps(node).FirstOrDefault(); + if (text != null) + { + if (text.Length > 1) + text = "(" + text + ")"; + stringBuilder.Append(text); + } + } + + return stringBuilder.ToString(); + } + private XElement CreateMorphemeElement(Morpheme morpheme) { var msaID = (int?) morpheme.Properties[HCParser.MsaID] ?? 0; diff --git a/Src/views/VwSelection.cpp b/Src/views/VwSelection.cpp index 6f13539dfc..e8922cdd1e 100644 --- a/Src/views/VwSelection.cpp +++ b/Src/views/VwSelection.cpp @@ -5315,6 +5315,7 @@ void VwTextSelection::MakeSubString(ITsString * ptss, int ichMin, int ichLim, IT int cch; CheckHr(ptss->GetBldr(&qtsb)); CheckHr(ptss->get_Length(&cch)); + if (ichLim < cch) CheckHr(qtsb->Replace(ichLim, cch, NULL, NULL)); if (ichMin) @@ -5342,16 +5343,25 @@ void VwTextSelection::MakeSubString(ITsString * ptss, int ichMin, int ichLim, IT if (wsNew <= 0) { - // Still don't have a writing system, so use the WS of the last run that the - // selection is located in. - int cRun; - CheckHr(m_qtsbProp->get_RunCount(&cRun)); - Assert(cRun > 0); - CheckHr(m_qtsbProp->get_Properties(cRun - 1, &qttp)); - CheckHr(qttp->GetIntPropValues(ktptWs, &var, &wsNew)); + if(m_qtsbProp) + { + // Still don't have a writing system, so use the WS of the last run that the + // selection is located in. + int cRun; + CheckHr(m_qtsbProp->get_RunCount(&cRun)); + Assert(cRun > 0); + CheckHr(m_qtsbProp->get_Properties(cRun - 1, &qttp)); + CheckHr(qttp->GetIntPropValues(ktptWs, &var, &wsNew)); + } } - Assert(wsNew > 0); + if(wsNew <= 0) + { + // After every effort no suitable source for a ws was found + // This is noteworty, but instead of failing we'll just leave the builder without a new ws + Assert(wsNew > 0); + return; + } // update the builder with the new writing system CheckHr(qtsb->get_Properties(0, &qttp)); ITsPropsBldrPtr qtpb;