Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Src/Common/Controls/DetailControls/ChooserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
using System;
using System.Windows.Forms;
using System.Linq;
using SIL.LCModel.Core.Text;
using SIL.FieldWorks.Common.Framework.DetailControls.Resources;
using SIL.LCModel;
using SIL.LCModel.DomainServices;
using SIL.LCModel.Infrastructure;
using SIL.FieldWorks.LexText.Controls;
using SIL.FieldWorks.Common.Controls;
using SIL.FieldWorks.Common.FwUtils;
using XCore;

namespace SIL.FieldWorks.Common.Framework.DetailControls
Expand Down Expand Up @@ -47,7 +45,7 @@ public override ObjectLabel Execute()
dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator, m_propertyTable,
m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.Prefix : InsertEntryDlg.MorphTypeFilterType.Suffix);
dlg.DisableAffixTypeMainPosAndSlot();
if (dlg.ShowDialog() == DialogResult.OK)
if (dlg.ShowDialog(m_propertyTable.GetValue<Form>("window")) == DialogResult.OK)
{
bool fCreated;
ILexEntry entry;
Expand Down
21 changes: 21 additions & 0 deletions Src/FwCoreDlgs/FwCoreDlgsTests/FwNewLangProjectModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public void FwNewLangProjectModel_VerifyCreateNewLangProject()
[TestCase("*", false)]
[TestCase("franç", false)] // upper ASCII is forbidden
[TestCase("\u0344", false)] // non-ASCII is forbidden
[TestCase("MyProject ", true)] // trailing space is trimmed, still valid (LT-22578)
[TestCase(" ", false)] // whitespace-only trims to empty -> invalid (LT-22578)
public void FwNewLangProjectModel_ProjectNameIsValid(string projName, bool expectedResult)
{
var testModel = new FwNewLangProjectModel
Expand All @@ -116,6 +118,25 @@ public void FwNewLangProjectModel_ProjectNameIsValid(string projName, bool expec
Assert.That(testModel.IsProjectNameValid, Is.EqualTo(expectedResult));
}

/// <summary>
/// The name is trimmed of surrounding whitespace when stored, so the validated name matches
/// the name used to create the project directory. Windows strips trailing spaces/dots from
/// folder names, so an untrimmed name crashes on creation (LT-22578).
/// </summary>
[TestCase("MyProject ", "MyProject", TestName = "TrailingSpace")]
[TestCase(" MyProject", "MyProject", TestName = "LeadingSpace")]
[TestCase(" MyProject ", "MyProject", TestName = "SurroundingSpace")]
[TestCase("My Project", "My Project", TestName = "InteriorSpacePreserved")]
public void FwNewLangProjectModel_ProjectName_TrimsSurroundingWhitespace(string input, string expected)
{
var testModel = new FwNewLangProjectModel
{
LoadProjectNameSetup = () => { },
ProjectName = input
};
Assert.That(testModel.ProjectName, Is.EqualTo(expected));
}

/// <summary/>
[Test]
public void FwNewLangProjectModel_ProjectNameIsUnique()
Expand Down
2 changes: 1 addition & 1 deletion Src/FwCoreDlgs/FwNewLangProjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public string ProjectName
get { return _projectName; }
set
{
_projectName = value;
_projectName = value?.Trim();
_steps[(int)CurrentStep].IsComplete = IsProjectNameValid;
LoadProjectNameSetup();
}
Expand Down
2 changes: 1 addition & 1 deletion Src/LexText/Morphology/InflAffixTemplateControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public bool OnInflTemplateAddInflAffixMsa(object cmd)

using (var chooser = MakeChooserWithExtantMsas(m_slot, cmd as XCore.Command))
{
chooser.ShowDialog();
chooser.ShowDialog(this);
if (chooser.DialogResult == DialogResult.OK)
{
if (chooser.ChosenObjects != null && chooser.ChosenObjects.Count() > 0)
Expand Down
Loading