Skip to content

Commit bd92048

Browse files
authored
Fix all-caps suggestions for contractions
Closes GH-36. Closes GH-40. Reviewed-by: Titus Wormer <[email protected]>
1 parent 845ab5a commit bd92048

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/suggest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function generate(context, memory, words, edits) {
314314
check(before + inject + nextAfter)
315315

316316
// Try upper-case if the original character was upper-cased.
317-
if (upper) {
317+
if (upper && inject !== inject.toUpperCase()) {
318318
inject = inject.toUpperCase()
319319

320320
check(before + inject + after)

test/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,30 @@ test('NSpell()', function (t) {
475475
'should include `warn: true` for warnings'
476476
)
477477

478+
st.deepEqual(
479+
us.suggest('dont'),
480+
[
481+
'dent',
482+
'cont',
483+
'font',
484+
'wont',
485+
'dint',
486+
'dolt',
487+
'don',
488+
"don't",
489+
'dona',
490+
'done',
491+
'dong',
492+
'dons',
493+
'dost',
494+
'dot',
495+
'Donn',
496+
'Mont',
497+
'ONT'
498+
],
499+
'should suggest alternatives including correct conjunction'
500+
)
501+
478502
st.end()
479503
})
480504

0 commit comments

Comments
 (0)