Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 1a7d2cc

Browse files
committed
Adding a test for checkers that do not provide suggest
1 parent 7741a26 commit 1a7d2cc

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

lib/corrections-view.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ export default class CorrectionsView {
4444
this.editor.buffer.file &&
4545
this.editor.buffer.file.path
4646
) {
47-
[
48-
projectPath,
49-
relativePath,
50-
] = atom.project.relativizePath(
51-
this.editor.buffer.file.path
52-
);
47+
[projectPath, relativePath] =
48+
atom.project.relativizePath(
49+
this.editor.buffer.file.path
50+
);
5351
}
5452

5553
const args = { id: this.id, projectPath, relativePath };

lib/spell-check-manager.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ class SpellCheckerManager {
317317
continue;
318318
}
319319

320+
// Do a little sanity checking.
321+
if (!checker.suggest) {
322+
this.log(
323+
'spell checker does not have a .suggest function',
324+
checker
325+
);
326+
continue;
327+
}
328+
320329
// Get the suggestions for this word.
321330
index = 0;
322331
priority = checker.getPriority();

lib/spell-check-view.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module.exports = SpellCheckView = class SpellCheckView {
2424
let marker;
2525
if (
2626
(marker = this.markerLayer.findMarkers({
27-
containsBufferPosition: this.editor.getCursorBufferPosition(),
27+
containsBufferPosition:
28+
this.editor.getCursorBufferPosition(),
2829
})[0])
2930
) {
3031
if (CorrectionsView == null) {
@@ -202,9 +203,8 @@ module.exports = SpellCheckView = class SpellCheckView {
202203
const currentScreenPosition = atom.views
203204
.getView(this.editor)
204205
.component.screenPositionForMouseEvent(mouseEvent);
205-
const currentBufferPosition = this.editor.bufferPositionForScreenPosition(
206-
currentScreenPosition
207-
);
206+
const currentBufferPosition =
207+
this.editor.bufferPositionForScreenPosition(currentScreenPosition);
208208

209209
// Check to see if the selected word is incorrect.
210210
if (

spec/spell-check-spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,8 @@ describe('Spell check', function () {
241241
editorElement,
242242
'spell-check:correct-misspelling'
243243
);
244-
correctionsElement = editorElement.querySelector(
245-
'.corrections'
246-
);
244+
correctionsElement =
245+
editorElement.querySelector('.corrections');
247246
expect(correctionsElement).toBeDefined();
248247
expect(
249248
correctionsElement.querySelectorAll('li').length

0 commit comments

Comments
 (0)