Skip to content

Commit 8d0651a

Browse files
committed
Minor fixes
- Fixed an issue with the classifier factory throwing an exception with ASPX files. Fixes #287. - Fixed a couple of issues when adding and removing sections in the configuration editor. Fixes #293. - Fixed handling of all uppercase words in the word splitter when they are being spell checked.
1 parent ae067c9 commit 8d0651a

4 files changed

Lines changed: 34 additions & 8 deletions

File tree

Source/VSSpellCheckerCommon/EditorConfig/EditorConfigSection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public EditorConfigSection()
142142
/// <param name="lines">An enumerable list of section lines</param>
143143
public EditorConfigSection(IEnumerable<SectionLine> lines)
144144
{
145-
this.SectionLines = new Collection<SectionLine>(lines.ToArray());
145+
this.SectionLines = new Collection<SectionLine>(lines.ToList());
146146
}
147147

148148
/// <summary>

Source/VSSpellCheckerCommon/WordSplitter.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// System : Visual Studio Spell Checker Package
33
// File : WordSplitter.cs
44
// Authors : Noah Richards, Roman Golovin, Michael Lehenbauer, Eric Woodruff
5-
// Updated : 03/12/2023
5+
// Updated : 06/14/2023
66
// Note : Copyright 2010-2023, Microsoft Corporation, All rights reserved
77
// Portions Copyright 2013-2023, Eric Woodruff, All rights reserved
88
//
@@ -542,7 +542,7 @@ public IEnumerable<T> GetWordsInText(string text)
542542
}
543543
else
544544
{
545-
int split = i;
545+
int split = i, start = i;
546546

547547
while(split < end)
548548
{
@@ -551,6 +551,13 @@ public IEnumerable<T> GetWordsInText(string text)
551551
while(split + 1 < end && Char.IsUpper(text[split + 1]))
552552
split++;
553553

554+
// If all uppercase, return the entire word
555+
if(i == start && split == end - 1)
556+
{
557+
yield return this.CreateSpan(i, end);
558+
break;
559+
}
560+
554561
i = split;
555562
split++;
556563

Source/VSSpellCheckerShared/Editors/SpellingConfigurationEditorControl.xaml.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// System : Visual Studio Spell Checker Package
33
// File : SpellConfigurationEditorControl.xaml.cs
44
// Author : Eric Woodruff (Eric@EWoodruff.us)
5-
// Updated : 05/15/2023
5+
// Updated : 06/15/2023
66
// Note : Copyright 2015-2023, Eric Woodruff, All rights reserved
77
//
88
// This file contains a user control used to edit spell checker configuration settings files
@@ -363,8 +363,14 @@ private void btnDeleteSection_Click(object sender, RoutedEventArgs e)
363363
int idx = lbSections.SelectedIndex;
364364

365365
lastSelectedSection = -1;
366+
366367
sections.RemoveAt(idx);
367-
configFile.Sections.RemoveAt(idx);
368+
369+
// Adjust the index when there is a root section
370+
if(configFile.Sections[0].IsRoot)
371+
configFile.Sections.RemoveAt(idx + 1);
372+
else
373+
configFile.Sections.RemoveAt(idx);
368374

369375
if(lbSections.Items.Count <= idx)
370376
idx--;
@@ -443,8 +449,18 @@ private void btnMoveUpDown_Click(object sender, RoutedEventArgs e)
443449
sections.RemoveAt(currentIndex);
444450
sections.Insert(newIndex, sectionToMove);
445451

446-
configFile.Sections.RemoveAt(currentIndex);
447-
configFile.Sections.Insert(newIndex, sectionToMove.Section);
452+
// Adjust the index when there is a root section
453+
if(configFile.Sections[0].IsRoot)
454+
{
455+
configFile.Sections.RemoveAt(currentIndex + 1);
456+
configFile.Sections.Insert(newIndex + 1, sectionToMove.Section);
457+
}
458+
else
459+
{
460+
configFile.Sections.RemoveAt(currentIndex);
461+
configFile.Sections.Insert(newIndex, sectionToMove.Section);
462+
}
463+
448464
suppressSectionChange = false;
449465

450466
lbSections.SelectedIndex = newIndex;

Source/VSSpellCheckerShared/ProjectSpellCheck/ClassifierFactory.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// System : Visual Studio Spell Checker Package
33
// File : ClassifierFactory.cs
44
// Author : Eric Woodruff (Eric@EWoodruff.us)
5-
// Updated : 03/22/2023
5+
// Updated : 06/15/2023
66
// Note : Copyright 2015-2023, Eric Woodruff, All rights reserved
77
//
88
// This file contains a class used to generate classifiers for files that need to be spell checked
@@ -149,6 +149,9 @@ public static bool IsCStyleCode(string filename)
149149
/// <returns>True if it does, false if not</returns>
150150
public static bool SupportsOldStyleXmlDocComments(string filename)
151151
{
152+
if(filename == null)
153+
return false;
154+
152155
string extension = Path.GetExtension(filename);
153156

154157
if(extensionMap == null)

0 commit comments

Comments
 (0)