Socket
Socket
Sign inDemoInstall

@codemirror/autocomplete

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/autocomplete - npm Package Compare versions

Comparing version 0.19.15 to 0.20.0

18

CHANGELOG.md

@@ -0,1 +1,19 @@

## 0.20.0 (2022-04-20)
### Breaking changes
`CompletionResult.span` has been renamed to `validFor`, and may now hold a function as well as a regular expression.
### Bug fixes
Remove code that dropped any options beyond the 300th one when matching and sorting option lists.
Completion will now apply to all cursors when there are multiple cursors.
### New features
`CompletionResult.update` can now be used to implement quick autocompletion updates in a synchronous way.
The @codemirror/closebrackets package was merged into this one.
## 0.19.15 (2022-03-23)

@@ -2,0 +20,0 @@

87

dist/index.d.ts

@@ -55,4 +55,3 @@ import * as _codemirror_state from '@codemirror/state';

other added widgets and the standard content. The default icons
have position 20, the label position 50, and the detail position
70.
have position 20, the label position 50, and the detail position 70.
*/

@@ -230,10 +229,10 @@ addToOptions?: {

/**
When given, further input that causes the part of the document
between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from` and `to` to
match this regular expression will not query the completion
source again, but continue with this list of options. This can
help a lot with responsiveness, since it allows the completion
list to be updated synchronously.
When given, further typing or deletion that causes the part of
the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from`
and `to` to match this regular expression or predicate function
will not query the completion source again, but continue with
this list of options. This can help a lot with responsiveness,
since it allows the completion list to be updated synchronously.
*/
span?: RegExp;
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean);
/**

@@ -244,6 +243,15 @@ By default, the library filters and scores completions. Set

other sources, unfiltered completions appear at the top of the
list of completions. `span` must not be given when `filter` is
`false`, because it only works when filtering.
list of completions. `validFor` must not be given when `filter`
is `false`, because it only works when filtering.
*/
filter?: boolean;
/**
Synchronously update the completion result after typing or
deletion. If given, this should not do any expensive work, since
it will be called during editor state updates. The function
should make sure (similar to
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the
completion still applies in the new state.
*/
update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null;
}

@@ -257,4 +265,5 @@ /**

/**
Convert a snippet template to a function that can apply it.
Snippets are written using syntax like this:
Convert a snippet template to a function that can
[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
using syntax like this:

@@ -339,2 +348,52 @@ "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"

/**
Configures bracket closing behavior for a syntax (via
[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"`
identifier.
*/
interface CloseBracketConfig {
/**
The opening brackets to close. Defaults to `["(", "[", "{", "'",
'"']`. Brackets may be single characters or a triple of quotes
(as in `"''''"`).
*/
brackets?: string[];
/**
Characters in front of which newly opened brackets are
automatically closed. Closing always happens in front of
whitespace. Defaults to `")]}:;>"`.
*/
before?: string;
}
/**
Extension to enable bracket-closing behavior. When a closeable
bracket is typed, its closing bracket is immediately inserted
after the cursor. When closing a bracket directly in front of a
closing bracket inserted by the extension, the cursor moves over
that bracket.
*/
declare function closeBrackets(): Extension;
/**
Command that implements deleting a pair of matching brackets when
the cursor is between them.
*/
declare const deleteBracketPair: StateCommand;
/**
Close-brackets related key bindings. Binds Backspace to
[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
*/
declare const closeBracketsKeymap: readonly KeyBinding[];
/**
Implements the extension's behavior on text insertion. If the
given string counts as a bracket in the language around the
selection, and replacing the selection with it requires custom
behavior (inserting a closing version or skipping past a
previously-closed bracket), this function returns a transaction
representing that custom behavior. (You only need this if you want
to programmatically insert brackets—the
[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
take care of running this for user input.)
*/
declare function insertBracket(state: EditorState, bracket: string): Transaction | null;
/**
Returns an extension that enables autocompletion.

@@ -381,2 +440,2 @@ */

export { Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, ifIn, ifNotIn, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
export { CloseBracketConfig, Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, ifIn, ifNotIn, insertBracket, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };

12

package.json
{
"name": "@codemirror/autocomplete",
"version": "0.19.15",
"version": "0.20.0",
"description": "Autocompletion for the CodeMirror code editor",

@@ -29,8 +29,6 @@ "scripts": {

"dependencies": {
"@codemirror/language": "^0.19.0",
"@codemirror/state": "^0.19.4",
"@codemirror/text": "^0.19.2",
"@codemirror/tooltip": "^0.19.12",
"@codemirror/view": "^0.19.0",
"@lezer/common": "^0.15.0"
"@codemirror/language": "^0.20.0",
"@codemirror/state": "^0.20.0",
"@codemirror/view": "^0.20.0",
"@lezer/common": "^0.16.0"
},

@@ -37,0 +35,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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