-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed loading of the default ignored words file in the absence of a default global configuration file. Fixes #223. - Fixed loading of ignored words files so that words starting with an invalid escape sequence have the leading backslash removed. Fixes #222. - Fixed saving words to the user dictionary file so that words added by other instances of Visual Studio are not lost. Fixes #219. - Updated the word splitter to split text on emoji characters. This prevents them from being included as part of the preceding/following word and fixes a crash in NHunSpell that can occur if they are included as part of the word when using non-US dictionaries. Fixes #216. Fixes #218. - Added the menu option Tools, Spell Checker, Disable/Enable in Current Session to disable/enable interactive spell checking in the current Visual Studio session. Closes #149.
- Loading branch information
1 parent
9bbd3ea
commit 1856b88
Showing
24 changed files
with
345 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<topic id="bb88f7d5-2491-457e-9ba3-8d7d0bbc8615" revisionNumber="1"> | ||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<introduction> | ||
<para>Changes in this release:</para> | ||
</introduction> | ||
|
||
<section> | ||
<content> | ||
<list class="bullet"> | ||
<listItem> | ||
<para>Fixed loading of the default ignored words file in the absence of a default global configuration | ||
file.</para> | ||
</listItem> | ||
|
||
<listItem> | ||
<para>Fixed loading of ignored words files so that words starting with an invalid escape sequence | ||
have the leading backslash removed.</para> | ||
</listItem> | ||
|
||
<listItem> | ||
<para>Fixed saving words to the user dictionary file so that words added by other instances of Visual | ||
Studio are not lost.</para> | ||
</listItem> | ||
|
||
<listItem> | ||
<para>Updated the word splitter to split text on emoji characters. This prevents them from being | ||
included as part of the preceding/following word and fixes a crash in NHunSpell that can occur if they are | ||
included as part of the word when using non-US dictionaries.</para> | ||
</listItem> | ||
|
||
<listItem> | ||
<para>Added the menu option <legacyBold>Tools</legacyBold>, <legacyBold>Spell Checker</legacyBold>, | ||
<legacyBold>Disable/Enable in Current Session</legacyBold> to temporarily disable and subsequently re-enable | ||
interactive spell checking in editors during the current Visual Studio session.</para> | ||
</listItem> | ||
|
||
</list> | ||
|
||
</content> | ||
</section> | ||
|
||
<relatedTopics> | ||
<link xlink:href="548dc6d7-6d08-4006-82b3-d5830be96f04" /> | ||
</relatedTopics> | ||
|
||
</developerConceptualDocument> | ||
</topic> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
// System : Visual Studio Spell Checker Package | ||
// File : SpellCheckerConfiguration.cs | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 04/18/2020 | ||
// Note : Copyright 2015-2020, Eric Woodruff, All rights reserved | ||
// Updated : 01/13/2021 | ||
// Note : Copyright 2015-2021, Eric Woodruff, All rights reserved | ||
// | ||
// This file contains the class used to contain the spell checker's configuration settings | ||
// | ||
|
@@ -508,10 +508,9 @@ public void Load(string filename) | |
|
||
try | ||
{ | ||
// Nothing to do if the file doesn't exist | ||
if(!File.Exists(filename)) | ||
return; | ||
|
||
// We go through the motions of loading the configuration file even if it doesn't exist. This | ||
// allows external files such as the default ignored words file to be loaded even if the default | ||
// global configuration file does not exist. | ||
var configuration = new SpellingConfigurationFile(filename, this); | ||
|
||
loadedConfigFiles.Add(filename); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
// System : Visual Studio Spell Checker Package | ||
// File : SpellingConfigurationFile.cs | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 10/05/2018 | ||
// Note : Copyright 2015-2018, Eric Woodruff, All rights reserved | ||
// Updated : 01/13/2021 | ||
// Note : Copyright 2015-2021, Eric Woodruff, All rights reserved | ||
// Compiler: Microsoft Visual C# | ||
// | ||
// This file contains the class used to load and save spell checker configuration files | ||
|
@@ -41,12 +41,12 @@ public class SpellingConfigurationFile | |
#region Private data members | ||
//===================================================================== | ||
|
||
private Dictionary<string, PropertyInfo> propertyCache; | ||
private readonly Dictionary<string, PropertyInfo> propertyCache; | ||
private readonly PropertyDescriptorCollection configCache, csoCache, cadCache; | ||
private readonly SpellCheckerConfiguration defaultConfig; | ||
|
||
private XDocument document; | ||
private XElement root; | ||
private readonly XDocument document; | ||
private readonly XElement root; | ||
|
||
#endregion | ||
|
||
|
@@ -139,7 +139,7 @@ public ConfigurationType ConfigurationType | |
public SpellingConfigurationFile(string filename, SpellCheckerConfiguration defaultConfig) | ||
{ | ||
if(String.IsNullOrWhiteSpace(filename)) | ||
throw new ArgumentNullException("filename", "Filename cannot be null or empty"); | ||
throw new ArgumentNullException(nameof(filename), "Filename cannot be null or empty"); | ||
|
||
this.Filename = filename; | ||
this.defaultConfig = defaultConfig; | ||
|
@@ -635,7 +635,7 @@ public bool ToBoolean(string propertyName) | |
!Boolean.TryParse(property.Value, out bool value)) | ||
{ | ||
object defaultValue = this.DefaultValueFor(propertyName); | ||
return (defaultValue != null) ? (bool)defaultValue : false; | ||
return (defaultValue != null) && (bool)defaultValue; | ||
} | ||
|
||
return value; | ||
|
@@ -675,7 +675,7 @@ public TEnum ToEnum<TEnum>(string propertyName) where TEnum : struct | |
!Enum.TryParse<TEnum>(property.Value, true, out TEnum value)) | ||
{ | ||
object defaultValue = this.DefaultValueFor(propertyName); | ||
value = (defaultValue != null) ? (TEnum)defaultValue : default(TEnum); | ||
value = (defaultValue != null) ? (TEnum)defaultValue : default; | ||
} | ||
|
||
return value; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
// System : Visual Studio Spell Checker Package | ||
// File : DictionarySettingsUserControl.xaml.cs | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 02/21/2020 | ||
// Note : Copyright 2014-2020, Eric Woodruff, All rights reserved | ||
// Updated : 01/13/2021 | ||
// Note : Copyright 2014-2021, Eric Woodruff, All rights reserved | ||
// | ||
// This file contains a user control used to edit the spell checker dictionary settings | ||
// | ||
|
@@ -889,7 +889,7 @@ private void btnExport_Click(object sender, RoutedEventArgs e) | |
} | ||
} | ||
|
||
Utility.SaveCustomDictionary(dlg.FileName, replaceWords, true, uniqueWords.OrderBy(w => w)); | ||
Utility.SaveCustomDictionary(dlg.FileName, replaceWords, true, uniqueWords); | ||
} | ||
catch(Exception ex) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
// System : Visual Studio Spell Checker Package | ||
// File : IgnoredWordsUserControl.xaml.cs | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 03/19/2020 | ||
// Note : Copyright 2014-2020, Eric Woodruff, All rights reserved | ||
// Updated : 01/13/2021 | ||
// Note : Copyright 2014-2021, Eric Woodruff, All rights reserved | ||
// | ||
// This file contains a user control used to edit the ignored words spell checker configuration settings | ||
// | ||
|
@@ -342,7 +342,7 @@ private void btnExport_Click(object sender, RoutedEventArgs e) | |
} | ||
} | ||
|
||
Utility.SaveCustomDictionary(dlg.FileName, replaceWords, false, uniqueWords.OrderBy(w => w)); | ||
Utility.SaveCustomDictionary(dlg.FileName, replaceWords, false, uniqueWords); | ||
} | ||
catch(Exception ex) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
// System : Visual Studio Spell Checker Package | ||
// File : GlobalDictionary.cs | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 02/21/2020 | ||
// Note : Copyright 2013-2020, Eric Woodruff, All rights reserved | ||
// Updated : 01/20/2021 | ||
// Note : Copyright 2013-2021, Eric Woodruff, All rights reserved | ||
// | ||
// This file contains a class that implements the global dictionary | ||
// | ||
|
@@ -179,20 +179,42 @@ public bool AddWordToDictionary(string word) | |
if(!dictionaryWordsFile.CanWriteToUserWordsFile(dictionaryFile)) | ||
return false; | ||
|
||
bool multipleWordsAdded = false; | ||
|
||
lock(dictionaryWords) | ||
{ | ||
var currentDictionary = new HashSet<string>(Utility.LoadUserDictionary(dictionaryWordsFile, false, | ||
false), StringComparer.OrdinalIgnoreCase); | ||
|
||
dictionaryWords.Add(word); | ||
|
||
// Sort and write all the words to the file. If under source control, this should minimize the | ||
// number of merge conflicts that could result if multiple people added words and they were all | ||
// written to the end of the file. | ||
File.WriteAllLines(dictionaryWordsFile, dictionaryWords.OrderBy(w => w)); | ||
// The word may have been added by another instance of Visual Studio. If so, don't save the change. | ||
if(!currentDictionary.Contains(word)) | ||
{ | ||
int wordCount = dictionaryWords.Count; | ||
|
||
// Add words added by other instances of Visual Studio not already in this copy of the | ||
// dictionary so that we don't lose them when the file is saved. All new ones will be | ||
// added as suggestions below. | ||
dictionaryWords.UnionWith(currentDictionary); | ||
|
||
multipleWordsAdded = (wordCount != dictionaryWords.Count); | ||
|
||
// Sort and write all the words to the file. If under source control, this should minimize the | ||
// number of merge conflicts that could result if multiple people added words and they were all | ||
// written to the end of the file. | ||
File.WriteAllLines(dictionaryWordsFile, dictionaryWords.OrderBy(w => w)); | ||
} | ||
} | ||
|
||
this.AddSuggestion(word); | ||
if(multipleWordsAdded) | ||
this.AddSuggestions(); | ||
else | ||
this.AddSuggestion(word); | ||
|
||
// Must pass the original word with mnemonics as it must match the span text | ||
this.NotifySpellingServicesOfChange(originalWord); | ||
// Must pass the original word with mnemonics as it must match the span text. If multiple words | ||
// were added from other instances, pass null to respell all text. | ||
this.NotifySpellingServicesOfChange(multipleWordsAdded ? null : originalWord); | ||
|
||
return true; | ||
} | ||
|
@@ -446,6 +468,17 @@ public static bool IsReadyForUse(CultureInfo language) | |
return true; | ||
} | ||
|
||
/// <summary> | ||
/// This is used to notify all registered spelling dictionary services of a change in status | ||
/// </summary> | ||
/// <remarks>This is used when turning the interactive spell checking on and off for the session</remarks> | ||
public static void NotifyChangeOfStatus() | ||
{ | ||
if(globalDictionaries != null) | ||
foreach(var g in globalDictionaries.Values) | ||
g.NotifySpellingServicesOfChange(null); | ||
} | ||
|
||
/// <summary> | ||
/// This is used to load the user dictionary words file | ||
/// </summary> | ||
|
Binary file not shown.
Oops, something went wrong.