shareable-twoslash-comments 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,8 +60,8 @@ define(function () { 'use strict';
|
|
|
60
60
|
|
|
61
61
|
var twoSlashQueryRegex = /(^[ \t]*)(\/\/\s*\^\?)/gm;
|
|
62
62
|
var twoSlashArrowQueryRegex = /(^.*)\/\/=>/gm;
|
|
63
|
-
function fillTwoSlashQueries(
|
|
64
|
-
return __awaiter(this,
|
|
63
|
+
function fillTwoSlashQueries(sandbox) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
65
|
function getLeftMostQuickInfo(_a) {
|
|
66
66
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
67
67
|
var col, quickInfoPos, quickInfoOffset, quickInfo;
|
|
@@ -156,7 +156,6 @@ define(function () { 'use strict';
|
|
|
156
156
|
return prevQuickInfoLines.join(model.getEOL());
|
|
157
157
|
}
|
|
158
158
|
var multilineEnabled, truncationDisabled, compactOutputEnabled, pauseOnError, model, worker, versionId, diagnostics, text, editOperations, matches, _i, matches_1, _a, match, queryType, textBeforeQuery, commentPrefix, isInlineArrowQuery, lineNumber, column, caretOffset, caretPos, quickInfoLine, quickInfoString, quickInfoComment, prevQuickInfoComment, prevQuickInfoLines, prevQuickInfoEndLine;
|
|
159
|
-
if (isUndoRedoChange === void 0) { isUndoRedoChange = false; }
|
|
160
159
|
return __generator(this, function (_b) {
|
|
161
160
|
switch (_b.label) {
|
|
162
161
|
case 0:
|
|
@@ -215,18 +214,19 @@ define(function () { 'use strict';
|
|
|
215
214
|
return [4 /*yield*/, getLeftMostQuickInfo({ line: quickInfoLine, column: column })];
|
|
216
215
|
case 5:
|
|
217
216
|
quickInfoString = _b.sent();
|
|
218
|
-
|
|
217
|
+
quickInfoString = multilineEnabled
|
|
219
218
|
? quickInfoString.replace(/\r?\n/g, model.getEOL() + commentPrefix)
|
|
220
|
-
: quickInfoString.replace(/\r?\n\s*/g, " ")
|
|
221
|
-
if (!truncationDisabled && !
|
|
222
|
-
|
|
219
|
+
: quickInfoString.replace(/\r?\n\s*/g, " ");
|
|
220
|
+
if (!truncationDisabled && !quickInfoString.includes("\n")) {
|
|
221
|
+
quickInfoString = truncate(quickInfoString, 100);
|
|
223
222
|
}
|
|
223
|
+
quickInfoComment = match[0] + (quickInfoString.length > 0 ? " " : "") + quickInfoString;
|
|
224
224
|
prevQuickInfoComment = getPreviousQuickInfoComment({ lineNumber: lineNumber });
|
|
225
225
|
prevQuickInfoLines = prevQuickInfoComment.split("\n").length;
|
|
226
226
|
prevQuickInfoEndLine = lineNumber + prevQuickInfoLines - 1;
|
|
227
227
|
if (prevQuickInfoComment !== quickInfoComment) {
|
|
228
228
|
editOperations.push({
|
|
229
|
-
range: new sandbox.monaco.Range(lineNumber,
|
|
229
|
+
range: new sandbox.monaco.Range(lineNumber, 1, prevQuickInfoEndLine, model.getLineContent(prevQuickInfoEndLine).length + 1),
|
|
230
230
|
text: quickInfoComment,
|
|
231
231
|
});
|
|
232
232
|
}
|
|
@@ -240,22 +240,7 @@ define(function () { 'use strict';
|
|
|
240
240
|
return [2 /*return*/];
|
|
241
241
|
}
|
|
242
242
|
if (editOperations.length > 0) {
|
|
243
|
-
|
|
244
|
-
model.popStackElement();
|
|
245
|
-
}
|
|
246
|
-
try {
|
|
247
|
-
if (isUndoRedoChange) {
|
|
248
|
-
model.applyEdits(editOperations);
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
sandbox.editor.executeEdits("shareable-twoslash-comments", editOperations);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
finally {
|
|
255
|
-
if (!isUndoRedoChange) {
|
|
256
|
-
model.pushStackElement();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
243
|
+
model.applyEdits(editOperations);
|
|
259
244
|
}
|
|
260
245
|
return [2 /*return*/];
|
|
261
246
|
}
|
|
@@ -282,6 +267,7 @@ define(function () { 'use strict';
|
|
|
282
267
|
function truncate(str, maxLength) {
|
|
283
268
|
return str.length > maxLength ? str.slice(0, maxLength) + "…" : str;
|
|
284
269
|
}
|
|
270
|
+
//# sourceMappingURL=utils.js.map
|
|
285
271
|
|
|
286
272
|
var debouncedFillTwoSlashQueries = debounce(fillTwoSlashQueries, 500);
|
|
287
273
|
var makePlugin = function (utils) {
|
|
@@ -289,7 +275,7 @@ define(function () { 'use strict';
|
|
|
289
275
|
id: "shareable-twoslash-comments",
|
|
290
276
|
displayName: "Shareable Twoslash Comments",
|
|
291
277
|
data: { firstMount: true },
|
|
292
|
-
shouldBeSelected: function () { return
|
|
278
|
+
shouldBeSelected: function () { return false; },
|
|
293
279
|
didMount: function (sandbox, container) {
|
|
294
280
|
container.style.paddingRight = "8px";
|
|
295
281
|
var sponsorBanner = document.createElement("a");
|
|
@@ -380,7 +366,7 @@ define(function () { 'use strict';
|
|
|
380
366
|
fillTwoSlashQueries(sandbox);
|
|
381
367
|
model.onDidChangeContent(function (e) {
|
|
382
368
|
if (e.isRedoing || e.isUndoing) {
|
|
383
|
-
fillTwoSlashQueries(sandbox
|
|
369
|
+
fillTwoSlashQueries(sandbox);
|
|
384
370
|
}
|
|
385
371
|
else {
|
|
386
372
|
debouncedFillTwoSlashQueries(sandbox);
|
|
@@ -406,6 +392,7 @@ define(function () { 'use strict';
|
|
|
406
392
|
};
|
|
407
393
|
return customPlugin;
|
|
408
394
|
};
|
|
395
|
+
//# sourceMappingURL=index.js.map
|
|
409
396
|
|
|
410
397
|
return makePlugin;
|
|
411
398
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shareable-twoslash-comments",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "A TypeScript Playground plugin that embeds twoslash (// ^?) type hints as literal comments in your code, making them easy to copy and share.",
|
|
6
6
|
"license": "MIT",
|