We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02cd678 commit bd4deb0Copy full SHA for bd4deb0
src/jsutils/suggestionList.js
@@ -80,15 +80,18 @@ class LexicalDistance {
80
for (let j = 1; j <= bLength; j++) {
81
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
82
83
- d[i][j] = Math.min(
84
- d[i - 1][j] + 1,
85
- d[i][j - 1] + 1,
86
- d[i - 1][j - 1] + cost,
+ let currentCell = Math.min(
+ d[i - 1][j] + 1, // delete
+ d[i][j - 1] + 1, // insert
+ d[i - 1][j - 1] + cost, // substitute
87
);
88
89
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
90
- d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
+ // transposition
91
+ currentCell = Math.min(currentCell, d[i - 2][j - 2] + 1);
92
}
93
+
94
+ d[i][j] = currentCell;
95
96
97
0 commit comments