Skip to content

Commit 844b414

Browse files
committed
simplify GetSuggestionsForError, use inline var declarations
1 parent 4f3efc6 commit 844b414

File tree

1 file changed

+7
-18
lines changed
  • src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents

1 file changed

+7
-18
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,33 +179,22 @@ internal ITextPointer GetNextSpellingErrorPosition(ITextPointer position, Logica
179179
// re-evaluating the error from scratch.
180180
internal List<string> GetSuggestionsForError(SpellingError error)
181181
{
182-
ITextPointer contextStart;
183-
ITextPointer contextEnd;
184-
ITextPointer contentStart;
185-
ITextPointer contentEnd;
186-
TextMap textMap;
187-
188-
List<string> suggestions = new();
189-
190182
//
191183
// IMPORTANT!!
192184
//
193185
// This logic here must match ScanRange, or else we might not
194186
// calculate the exact same error. Keep the two methods in sync!
195187
//
196188

197-
XmlLanguage language;
198-
CultureInfo culture = GetCurrentCultureAndLanguage(error.Start, out language);
199-
if (culture == null || !_spellerInterop.CanSpellCheck(culture))
200-
{
201-
// Return an empty list.
202-
}
203-
else
189+
List<string> suggestions = new();
190+
CultureInfo culture = GetCurrentCultureAndLanguage(error.Start, out XmlLanguage language);
191+
192+
if (culture is not null || _spellerInterop.CanSpellCheck(culture))
204193
{
205-
ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out contentStart, out contextStart);
206-
ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out contentEnd, out contextEnd);
194+
ExpandToWordBreakAndContext(error.Start, LogicalDirection.Backward, language, out ITextPointer contentStart, out ITextPointer contextStart);
195+
ExpandToWordBreakAndContext(error.End, LogicalDirection.Forward, language, out ITextPointer contentEnd, out ITextPointer contextEnd);
207196

208-
textMap = new TextMap(contextStart, contextEnd, contentStart, contentEnd);
197+
TextMap textMap = new(contextStart, contextEnd, contentStart, contentEnd);
209198

210199
SetCulture(culture);
211200

0 commit comments

Comments
 (0)