@codemirror/autocomplete
Advanced tools
Comparing version 0.19.9 to 0.19.10
@@ -0,1 +1,11 @@ | ||
## 0.19.10 (2022-01-05) | ||
### Bug fixes | ||
Make sure the info tooltip is hidden when the selected option is scrolled out of view. | ||
Fix a bug in the completion ranking that would sometimes give options that match the input by word start chars higher scores than appropriate. | ||
Options are now sorted (ascending) by length when their match score is otherwise identical. | ||
## 0.19.9 (2021-11-26) | ||
@@ -2,0 +12,0 @@ |
@@ -245,3 +245,3 @@ import { Annotation, Facet, combineConfig, StateEffect, StateField, Prec, EditorSelection, Text } from '@codemirror/state'; | ||
let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1; | ||
let hasLower = /[a-z]/.test(word); | ||
let hasLower = /[a-z]/.test(word), wordAdjacent = true; | ||
// Go over the option's text, scanning for the various kinds of matches | ||
@@ -268,22 +268,26 @@ for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* NonWord */; i < e && byWordTo < len;) { | ||
: ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Upper */ : ch != ch.toUpperCase() ? 2 /* Lower */ : 0 /* NonWord */); | ||
if ((type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) && | ||
(chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))) | ||
byWord[byWordTo++] = i; | ||
if (!i || type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) { | ||
if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true))) | ||
byWord[byWordTo++] = i; | ||
else if (byWord.length) | ||
wordAdjacent = false; | ||
} | ||
prevType = type; | ||
i += codePointSize(next); | ||
} | ||
if (byWordTo == len && byWord[0] == 0) | ||
if (byWordTo == len && byWord[0] == 0 && wordAdjacent) | ||
return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0), byWord, word); | ||
if (adjacentTo == len && adjacentStart == 0) | ||
return [-200 /* CaseFold */, 0, adjacentEnd]; | ||
return [-200 /* CaseFold */ - word.length, 0, adjacentEnd]; | ||
if (direct > -1) | ||
return [-700 /* NotStart */, direct, direct + this.pattern.length]; | ||
return [-700 /* NotStart */ - word.length, direct, direct + this.pattern.length]; | ||
if (adjacentTo == len) | ||
return [-200 /* CaseFold */ + -700 /* NotStart */, adjacentStart, adjacentEnd]; | ||
return [-200 /* CaseFold */ + -700 /* NotStart */ - word.length, adjacentStart, adjacentEnd]; | ||
if (byWordTo == len) | ||
return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */, byWord, word); | ||
return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */ + | ||
(wordAdjacent ? 0 : -1100 /* Gap */), byWord, word); | ||
return chars.length == 2 ? null : this.result((any[0] ? -700 /* NotStart */ : 0) + -200 /* CaseFold */ + -1100 /* Gap */, any, word); | ||
} | ||
result(score, positions, word) { | ||
let result = [score], i = 1; | ||
let result = [score - word.length], i = 1; | ||
for (let pos of positions) { | ||
@@ -484,8 +488,10 @@ let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1); | ||
return null; | ||
let rect = this.dom.getBoundingClientRect(), infoRect = this.info.getBoundingClientRect(); | ||
if (rect.top > innerHeight - 10 || rect.bottom < 10) | ||
let listRect = this.dom.getBoundingClientRect(); | ||
let infoRect = this.info.getBoundingClientRect(); | ||
let selRect = sel.getBoundingClientRect(); | ||
if (selRect.top > Math.min(innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10) | ||
return null; | ||
let top = Math.max(0, Math.min(sel.getBoundingClientRect().top, innerHeight - infoRect.height)) - rect.top; | ||
let top = Math.max(0, Math.min(selRect.top, innerHeight - infoRect.height)) - listRect.top; | ||
let left = this.view.textDirection == Direction.RTL; | ||
let spaceLeft = rect.left, spaceRight = innerWidth - rect.right; | ||
let spaceLeft = listRect.left, spaceRight = innerWidth - listRect.right; | ||
if (left && spaceLeft < Math.min(infoRect.width, spaceRight)) | ||
@@ -492,0 +498,0 @@ left = false; |
{ | ||
"name": "@codemirror/autocomplete", | ||
"version": "0.19.9", | ||
"version": "0.19.10", | ||
"description": "Autocompletion for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139808
3222