Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/search

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/search - npm Package Compare versions

Comparing version 0.19.1 to 0.19.2

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## 0.19.2 (2021-09-16)
### Bug fixes
`selectNextOccurrence` will now only select partial words if the current main selection hold a partial word.
Explicitly set the button's type to prevent the browser from submitting forms wrapped around the editor.
## 0.19.1 (2021-09-06)

@@ -2,0 +10,0 @@

37

dist/index.js

@@ -477,12 +477,23 @@ import { EditorView, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view';

function findNextOccurrence(state, query) {
let { ranges } = state.selection;
let ahead = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to).next();
if (!ahead.done)
return ahead.value;
let cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
while (!cursor.next().done) {
if (!ranges.some(r => r.from === cursor.value.from))
let { main, ranges } = state.selection;
let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;
for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
cursor.next();
if (cursor.done) {
if (cycled)
return null;
cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
cycled = true;
}
else {
if (cycled && ranges.some(r => r.from == cursor.value.from))
continue;
if (fullWord) {
let word = state.wordAt(cursor.value.from);
if (!word || word.from != cursor.value.from || word.to != cursor.value.to)
continue;
}
return cursor.value;
}
}
return null;
}

@@ -504,3 +515,3 @@ /**

dispatch(state.update({
selection: state.selection.addRange(EditorSelection.range(range.from, range.to)),
selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),
scrollIntoView: true

@@ -768,2 +779,4 @@ }));

let { state } = view, { from, to } = state.selection.main;
if (state.readOnly)
return false;
let next = query.nextMatch(state.doc, from, from);

@@ -794,2 +807,4 @@ if (!next)

const replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {
if (view.state.readOnly)
return false;
let changes = query.matchAll(view.state.doc, 1e9).map(match => {

@@ -932,3 +947,3 @@ let { from, to } = match;

function button(name, onclick, content) {
return elt("button", { class: "cm-button", name, onclick }, content);
return elt("button", { class: "cm-button", name, onclick, type: "button" }, content);
}

@@ -946,3 +961,3 @@ let panel = elt("div", { onkeydown: keydown, class: "cm-search" }, [

button("replaceAll", () => replaceAll(conf.view), [phrase("replace all")]),
elt("button", { name: "close", onclick: () => closeSearchPanel(conf.view), "aria-label": phrase("close") }, ["×"])
elt("button", { name: "close", onclick: () => closeSearchPanel(conf.view), "aria-label": phrase("close"), type: "button" }, ["×"])
]);

@@ -949,0 +964,0 @@ return panel;

{
"name": "@codemirror/search",
"version": "0.19.1",
"version": "0.19.2",
"description": "Search functionality for the CodeMirror code editor",

@@ -31,3 +31,3 @@ "scripts": {

"@codemirror/rangeset": "^0.19.0",
"@codemirror/state": "^0.19.0",
"@codemirror/state": "^0.19.2",
"@codemirror/text": "^0.19.0",

@@ -34,0 +34,0 @@ "@codemirror/view": "^0.19.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc