@codemirror/search
Advanced tools
Comparing version 6.5.6 to 6.5.7
@@ -0,1 +1,9 @@ | ||
## 6.5.7 (2024-11-01) | ||
### Bug fixes | ||
Fix an issue where `findNext` and `findPrevious` would do nothing when the only match in the document was partially selected. | ||
Fix an infinite loop in `SearchCursor` when the normalizer function deletes characters. | ||
## 6.5.6 (2024-02-07) | ||
@@ -2,0 +10,0 @@ |
@@ -82,15 +82,16 @@ import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view'; | ||
let norm = this.normalize(str); | ||
for (let i = 0, pos = start;; i++) { | ||
let code = norm.charCodeAt(i); | ||
let match = this.match(code, pos, this.bufferPos + this.bufferStart); | ||
if (i == norm.length - 1) { | ||
if (match) { | ||
this.value = match; | ||
return this; | ||
if (norm.length) | ||
for (let i = 0, pos = start;; i++) { | ||
let code = norm.charCodeAt(i); | ||
let match = this.match(code, pos, this.bufferPos + this.bufferStart); | ||
if (i == norm.length - 1) { | ||
if (match) { | ||
this.value = match; | ||
return this; | ||
} | ||
break; | ||
} | ||
break; | ||
if (pos == start && i < str.length && str.charCodeAt(i) == code) | ||
pos++; | ||
} | ||
if (pos == start && i < str.length && str.charCodeAt(i) == code) | ||
pos++; | ||
} | ||
} | ||
@@ -652,5 +653,7 @@ } | ||
let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping(); | ||
if (cursor.done) | ||
cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping(); | ||
return cursor.done ? null : cursor.value; | ||
if (cursor.done) { | ||
let end = Math.min(state.doc.length, curFrom + this.spec.unquoted.length); | ||
cursor = stringCursor(this.spec, state, 0, end).nextOverlapping(); | ||
} | ||
return cursor.done || cursor.value.from == curFrom && cursor.value.to == curTo ? null : cursor.value; | ||
} | ||
@@ -673,4 +676,6 @@ // Searching in reverse is, rather than implementing an inverted search | ||
prevMatch(state, curFrom, curTo) { | ||
return this.prevMatchInRange(state, 0, curFrom) || | ||
this.prevMatchInRange(state, curTo, state.doc.length); | ||
let found = this.prevMatchInRange(state, 0, curFrom); | ||
if (!found) | ||
found = this.prevMatchInRange(state, Math.max(0, curTo - this.spec.unquoted.length), state.doc.length); | ||
return found && (found.from != curFrom || found.to != curTo) ? found : null; | ||
} | ||
@@ -677,0 +682,0 @@ getReplacement(_result) { return this.spec.unquote(this.spec.replace); } |
{ | ||
"name": "@codemirror/search", | ||
"version": "6.5.6", | ||
"version": "6.5.7", | ||
"description": "Search functionality for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
133454
2812