Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -177,36 +177,24 @@ internal ITextPointer GetNextSpellingErrorPosition(ITextPointer position, Logica
// for an error range.
// This method actually runs the speller on the specified text,
// re-evaluating the error from scratch.
internal IList GetSuggestionsForError(SpellingError error)
internal List<string> GetSuggestionsForError(SpellingError error)
{
ITextPointer contextStart;
ITextPointer contextEnd;
ITextPointer contentStart;
ITextPointer contentEnd;
TextMap textMap;
ArrayList suggestions;

suggestions = new ArrayList(1);

//
// IMPORTANT!!
//
// This logic here must match ScanRange, or else we might not
// calculate the exact same error. Keep the two methods in sync!
//

XmlLanguage language;
CultureInfo culture = GetCurrentCultureAndLanguage(error.Start, out language);
if (culture == null || !_spellerInterop.CanSpellCheck(culture))
{
// Return an empty list.
}
else
List<string> suggestions = new(4);
CultureInfo culture = GetCurrentCultureAndLanguage(error.Start, out XmlLanguage language);

if (culture is not null && _spellerInterop.CanSpellCheck(culture))
{
ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out contentStart, out contextStart);
ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out contentEnd, out contextEnd);
ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out ITextPointer contentStart, out ITextPointer contextStart);
ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out ITextPointer contentEnd, out ITextPointer contextEnd);

textMap = new TextMap(contextStart, contextEnd, contentStart, contentEnd);
TextMap textMap = new(contextStart, contextEnd, contentStart, contentEnd);

SetCulture(culture);

Expand Down Expand Up @@ -915,7 +903,7 @@ private bool ScanErrorTextSegment(SpellerInteropBase.ISpellerSegment textSegment
{
if (textSegment.SubSegments.Count == 0)
{
ArrayList suggestions = (ArrayList)data.Data;
List<string> suggestions = (List<string>)data.Data;
if(textSegment.Suggestions.Count > 0)
{
foreach(string suggestion in textSegment.Suggestions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,7 @@ public void IgnoreAll()
/// </remarks>
public IEnumerable<string> Suggestions
{
get
{
IList suggestions = _speller.GetSuggestionsForError(this);

for (int i=0; i<suggestions.Count; i++)
{
yield return (string)suggestions[i];
}
}
get => _speller.GetSuggestionsForError(this);
}

#endregion Public Properties
Expand Down