Socket
Socket
Sign inDemoInstall

vscode-languageserver-textdocument

Package Overview
Dependencies
Maintainers
8
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-languageserver-textdocument - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

lib/esm/package.json

4

lib/esm/main.d.ts
/**
* A tagging type for string properties that are actually URIs.
*/
export declare type DocumentUri = string;
export type DocumentUri = string;
/**

@@ -79,3 +79,3 @@ * Position in a text document expressed as zero-based line and character offset.

*/
export declare type TextDocumentContentChangeEvent = {
export type TextDocumentContentChangeEvent = {
/**

@@ -82,0 +82,0 @@ * The range of the document that changed.

@@ -6,13 +6,4 @@ /* --------------------------------------------------------------------------------------------

'use strict';
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var FullTextDocument = /** @class */ (function () {
function FullTextDocument(uri, languageId, version, content) {
class FullTextDocument {
constructor(uri, languageId, version, content) {
this._uri = uri;

@@ -24,48 +15,35 @@ this._languageId = languageId;

}
Object.defineProperty(FullTextDocument.prototype, "uri", {
get: function () {
return this._uri;
},
enumerable: false,
configurable: true
});
Object.defineProperty(FullTextDocument.prototype, "languageId", {
get: function () {
return this._languageId;
},
enumerable: false,
configurable: true
});
Object.defineProperty(FullTextDocument.prototype, "version", {
get: function () {
return this._version;
},
enumerable: false,
configurable: true
});
FullTextDocument.prototype.getText = function (range) {
get uri() {
return this._uri;
}
get languageId() {
return this._languageId;
}
get version() {
return this._version;
}
getText(range) {
if (range) {
var start = this.offsetAt(range.start);
var end = this.offsetAt(range.end);
const start = this.offsetAt(range.start);
const end = this.offsetAt(range.end);
return this._content.substring(start, end);
}
return this._content;
};
FullTextDocument.prototype.update = function (changes, version) {
for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
var change = changes_1[_i];
}
update(changes, version) {
for (let change of changes) {
if (FullTextDocument.isIncremental(change)) {
// makes sure start is before end
var range = getWellformedRange(change.range);
const range = getWellformedRange(change.range);
// update content
var startOffset = this.offsetAt(range.start);
var endOffset = this.offsetAt(range.end);
const startOffset = this.offsetAt(range.start);
const endOffset = this.offsetAt(range.end);
this._content = this._content.substring(0, startOffset) + change.text + this._content.substring(endOffset, this._content.length);
// update the offsets
var startLine = Math.max(range.start.line, 0);
var endLine = Math.max(range.end.line, 0);
var lineOffsets = this._lineOffsets;
var addedLineOffsets = computeLineOffsets(change.text, false, startOffset);
const startLine = Math.max(range.start.line, 0);
const endLine = Math.max(range.end.line, 0);
let lineOffsets = this._lineOffsets;
const addedLineOffsets = computeLineOffsets(change.text, false, startOffset);
if (endLine - startLine === addedLineOffsets.length) {
for (var i = 0, len = addedLineOffsets.length; i < len; i++) {
for (let i = 0, len = addedLineOffsets.length; i < len; i++) {
lineOffsets[i + startLine + 1] = addedLineOffsets[i];

@@ -76,3 +54,3 @@ }

if (addedLineOffsets.length < 10000) {
lineOffsets.splice.apply(lineOffsets, __spreadArray([startLine + 1, endLine - startLine], addedLineOffsets, false));
lineOffsets.splice(startLine + 1, endLine - startLine, ...addedLineOffsets);
}

@@ -83,5 +61,5 @@ else { // avoid too many arguments for splice

}
var diff = change.text.length - (endOffset - startOffset);
const diff = change.text.length - (endOffset - startOffset);
if (diff !== 0) {
for (var i = startLine + 1 + addedLineOffsets.length, len = lineOffsets.length; i < len; i++) {
for (let i = startLine + 1 + addedLineOffsets.length, len = lineOffsets.length; i < len; i++) {
lineOffsets[i] = lineOffsets[i] + diff;

@@ -100,4 +78,4 @@ }

this._version = version;
};
FullTextDocument.prototype.getLineOffsets = function () {
}
getLineOffsets() {
if (this._lineOffsets === undefined) {

@@ -107,7 +85,7 @@ this._lineOffsets = computeLineOffsets(this._content, true);

return this._lineOffsets;
};
FullTextDocument.prototype.positionAt = function (offset) {
}
positionAt(offset) {
offset = Math.max(Math.min(offset, this._content.length), 0);
var lineOffsets = this.getLineOffsets();
var low = 0, high = lineOffsets.length;
let lineOffsets = this.getLineOffsets();
let low = 0, high = lineOffsets.length;
if (high === 0) {

@@ -117,3 +95,3 @@ return { line: 0, character: offset };

while (low < high) {
var mid = Math.floor((low + high) / 2);
let mid = Math.floor((low + high) / 2);
if (lineOffsets[mid] > offset) {

@@ -128,7 +106,7 @@ high = mid;

// or array.length if no line offset is larger than the current offset
var line = low - 1;
return { line: line, character: offset - lineOffsets[line] };
};
FullTextDocument.prototype.offsetAt = function (position) {
var lineOffsets = this.getLineOffsets();
let line = low - 1;
return { line, character: offset - lineOffsets[line] };
}
offsetAt(position) {
let lineOffsets = this.getLineOffsets();
if (position.line >= lineOffsets.length) {

@@ -140,26 +118,21 @@ return this._content.length;

}
var lineOffset = lineOffsets[position.line];
var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
let lineOffset = lineOffsets[position.line];
let nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
};
Object.defineProperty(FullTextDocument.prototype, "lineCount", {
get: function () {
return this.getLineOffsets().length;
},
enumerable: false,
configurable: true
});
FullTextDocument.isIncremental = function (event) {
var candidate = event;
}
get lineCount() {
return this.getLineOffsets().length;
}
static isIncremental(event) {
let candidate = event;
return candidate !== undefined && candidate !== null &&
typeof candidate.text === 'string' && candidate.range !== undefined &&
(candidate.rangeLength === undefined || typeof candidate.rangeLength === 'number');
};
FullTextDocument.isFull = function (event) {
var candidate = event;
}
static isFull(event) {
let candidate = event;
return candidate !== undefined && candidate !== null &&
typeof candidate.text === 'string' && candidate.range === undefined && candidate.rangeLength === undefined;
};
return FullTextDocument;
}());
}
}
export var TextDocument;

@@ -199,5 +172,5 @@ (function (TextDocument) {

function applyEdits(document, edits) {
var text = document.getText();
var sortedEdits = mergeSort(edits.map(getWellformedEdit), function (a, b) {
var diff = a.range.start.line - b.range.start.line;
let text = document.getText();
let sortedEdits = mergeSort(edits.map(getWellformedEdit), (a, b) => {
let diff = a.range.start.line - b.range.start.line;
if (diff === 0) {

@@ -208,7 +181,6 @@ return a.range.start.character - b.range.start.character;

});
var lastModifiedOffset = 0;
var spans = [];
for (var _i = 0, sortedEdits_1 = sortedEdits; _i < sortedEdits_1.length; _i++) {
var e = sortedEdits_1[_i];
var startOffset = document.offsetAt(e.range.start);
let lastModifiedOffset = 0;
const spans = [];
for (const e of sortedEdits) {
let startOffset = document.offsetAt(e.range.start);
if (startOffset < lastModifiedOffset) {

@@ -235,12 +207,12 @@ throw new Error('Overlapping edit');

}
var p = (data.length / 2) | 0;
var left = data.slice(0, p);
var right = data.slice(p);
const p = (data.length / 2) | 0;
const left = data.slice(0, p);
const right = data.slice(p);
mergeSort(left, compare);
mergeSort(right, compare);
var leftIdx = 0;
var rightIdx = 0;
var i = 0;
let leftIdx = 0;
let rightIdx = 0;
let i = 0;
while (leftIdx < left.length && rightIdx < right.length) {
var ret = compare(left[leftIdx], right[rightIdx]);
let ret = compare(left[leftIdx], right[rightIdx]);
if (ret <= 0) {

@@ -263,7 +235,6 @@ // smaller_equal -> take left to preserve order

}
function computeLineOffsets(text, isAtLineStart, textOffset) {
if (textOffset === void 0) { textOffset = 0; }
var result = isAtLineStart ? [textOffset] : [];
for (var i = 0; i < text.length; i++) {
var ch = text.charCodeAt(i);
function computeLineOffsets(text, isAtLineStart, textOffset = 0) {
const result = isAtLineStart ? [textOffset] : [];
for (let i = 0; i < text.length; i++) {
let ch = text.charCodeAt(i);
if (ch === 13 /* CharCode.CarriageReturn */ || ch === 10 /* CharCode.LineFeed */) {

@@ -279,4 +250,4 @@ if (ch === 13 /* CharCode.CarriageReturn */ && i + 1 < text.length && text.charCodeAt(i + 1) === 10 /* CharCode.LineFeed */) {

function getWellformedRange(range) {
var start = range.start;
var end = range.end;
const start = range.start;
const end = range.end;
if (start.line > end.line || (start.line === end.line && start.character > end.character)) {

@@ -288,7 +259,7 @@ return { start: end, end: start };

function getWellformedEdit(textEdit) {
var range = getWellformedRange(textEdit.range);
const range = getWellformedRange(textEdit.range);
if (range !== textEdit.range) {
return { newText: textEdit.newText, range: range };
return { newText: textEdit.newText, range };
}
return textEdit;
}
/**
* A tagging type for string properties that are actually URIs.
*/
export declare type DocumentUri = string;
export type DocumentUri = string;
/**

@@ -79,3 +79,3 @@ * Position in a text document expressed as zero-based line and character offset.

*/
export declare type TextDocumentContentChangeEvent = {
export type TextDocumentContentChangeEvent = {
/**

@@ -82,0 +82,0 @@ * The range of the document that changed.

@@ -229,3 +229,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

TextDocument.applyEdits = applyEdits;
})(TextDocument = exports.TextDocument || (exports.TextDocument = {}));
})(TextDocument || (exports.TextDocument = TextDocument = {}));
function mergeSort(data, compare) {

@@ -232,0 +232,0 @@ if (data.length <= 1) {

{
"name": "vscode-languageserver-textdocument",
"description": "A simple text document implementation for Node LSP servers",
"version": "1.0.10",
"version": "1.0.11",
"author": "Microsoft Corporation",

@@ -17,3 +17,9 @@ "license": "MIT",

"typings": "./lib/umd/main",
"module": "./lib/esm/main.js",
"exports": {
".": {
"browser": "./lib/esm/main.js",
"import": "./lib/esm/main.js",
"default": "./lib/umd/main.js"
}
},
"scripts": {

@@ -23,3 +29,3 @@ "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail",

"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"clean": "node ../node_modules/rimraf/bin.js lib",
"clean": "node ../node_modules/.bin/rimraf lib",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",

@@ -29,3 +35,3 @@ "lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",

"all": "npm run clean && npm run compile && npm run lint && npm run test",
"compile:esm": "node ../build/bin/tsc -b ./tsconfig.esm.publish.json",
"compile:esm": "node ../build/bin/tsc -b ./tsconfig.esm.publish.json && node ../build/bin/fix-esm",
"compile:umd": "node ../build/bin/tsc -b ./tsconfig.umd.publish.json",

@@ -32,0 +38,0 @@ "all:publish": "git clean -xfd . && npm install && npm run compile:esm && npm run compile:umd && npm run lint && npm run test",

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