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

@codemirror/language

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/language - npm Package Compare versions

Comparing version 0.17.5 to 0.18.0

12

CHANGELOG.md

@@ -0,1 +1,13 @@

## 0.18.0 (2021-03-03)
### Breaking changes
The `Language` constructor takes an additional argument that provides the top node type.
### New features
`Language` instances now have a `topNode` property giving their top node type.
`TreeIndentContext` now has a `continue` method that allows an indenter to defer to the indentation of the parent nodes.
## 0.17.5 (2021-02-19)

@@ -2,0 +14,0 @@

7

dist/index.d.ts

@@ -1,2 +0,2 @@

import { NodeProp, Input, ParseContext, PartialParse, Tree, TreeFragment, SyntaxNode } from 'lezer-tree';
import { NodeProp, NodeType, Input, ParseContext, PartialParse, Tree, TreeFragment, SyntaxNode } from 'lezer-tree';
import { Parser, ParserConfig } from 'lezer';

@@ -22,2 +22,3 @@ import { Facet, Extension, EditorState } from '@codemirror/state';

}>;
readonly topNode: NodeType;
readonly extension: Extension;

@@ -31,3 +32,3 @@ parser: {

startParse(input: Input, pos: number, context: EditorParseContext): PartialParse;
}, extraExtensions?: Extension[]);
}, topNode: NodeType, extraExtensions?: Extension[]);
isActiveAt(state: EditorState, pos: number): boolean;

@@ -118,2 +119,3 @@ findRegions(state: EditorState): {

declare class TreeIndentContext extends IndentContext {
private base;
readonly pos: number;

@@ -123,2 +125,3 @@ readonly node: SyntaxNode;

get baseIndent(): number;
continue(): number | null;
}

@@ -125,0 +128,0 @@ declare function delimitedIndent({ closing, align, units }: {

@@ -35,4 +35,7 @@ import { NodeProp, Tree, TreeFragment, NodeType } from 'lezer-tree';

/// facet used for this language.
data, parser, extraExtensions = []) {
data, parser,
/// The node type of the top node of trees produced by this parser.
topNode, extraExtensions = []) {
this.data = data;
this.topNode = topNode;
// Kludge to define EditorState.tree as a debugging helper,

@@ -109,3 +112,3 @@ // without the EditorState package actually knowing about

constructor(data, parser) {
super(data, parser);
super(data, parser, parser.topNode);
this.parser = parser;

@@ -660,8 +663,3 @@ }

}
for (; tree; tree = tree.parent) {
let strategy = indentStrategy(tree);
if (strategy)
return strategy(new TreeIndentContext(cx, pos, tree));
}
return null;
return indentFrom(tree, pos, cx);
}

@@ -683,2 +681,10 @@ function ignoreClosed(cx) {

}
function indentFrom(node, pos, base) {
for (; node; node = node.parent) {
let strategy = indentStrategy(node);
if (strategy)
return strategy(new TreeIndentContext(base, pos, node));
}
return null;
}
function topIndent() { return 0; }

@@ -696,2 +702,3 @@ /// Objects of this type provide context information and helper

super(base.state, base.options);
this.base = base;
this.pos = pos;

@@ -723,2 +730,8 @@ this.node = node;

}
/// Continue looking for indentations in the node's parent nodes,
/// and return the result of that.
continue() {
let parent = this.node.parent;
return parent ? indentFrom(parent, this.pos, this.base) : 0;
}
}

@@ -725,0 +738,0 @@ function isParent(parent, of) {

{
"name": "@codemirror/language",
"version": "0.17.5",
"version": "0.18.0",
"description": "Language support infrastructure for the CodeMirror code editor",

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

"dependencies": {
"@codemirror/state": "^0.17.0",
"@codemirror/text": "^0.17.0",
"@codemirror/view": "^0.17.0",
"lezer": "^0.13.0",
"@codemirror/state": "^0.18.0",
"@codemirror/text": "^0.18.0",
"@codemirror/view": "^0.18.0",
"lezer": "^0.13.4",
"lezer-tree": "^0.13.0"

@@ -35,0 +35,0 @@ },

Sorry, the diff of this file is not supported yet

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