shareable-twoslash-comments 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A TypeScript Playground plugin that embeds twoslash (// ^?) type hints as literal comments in your code, making them easy to copy and share.
4
4
 
5
+ https://github.com/user-attachments/assets/2224eec7-3011-4a08-b157-9eb6da700675
6
+
5
7
  ## Running this plugin
6
8
 
7
9
  - [Click this link](https://www.typescriptlang.org/play?install-plugin=shareable-twoslash-comments) to install
package/dist/index.js CHANGED
@@ -60,12 +60,13 @@ define(function () { 'use strict';
60
60
 
61
61
  var twoSlashQueryRegex = /(^[ \t]*)(\/\/\s*\^\?)/gm;
62
62
  var fillTwoSlashQueries = function (sandbox) { return __awaiter(void 0, void 0, void 0, function () {
63
- var multilineEnabled, model, worker, diagnostics, text, editOperations, _i, _a, match, commentPrefix, caretOffset, caretPos, quickInfoPos, quickInfoOffset, quickInfo, quickInfoString, quickInfoComment, prevQuickInfoComment, prevQuickInfoLines, prevQuickInfoEndLine;
63
+ var multilineEnabled, truncationDisabled, model, worker, diagnostics, text, editOperations, _i, _a, match, commentPrefix, caretOffset, caretPos, quickInfoPos, quickInfoOffset, quickInfo, quickInfoString, quickInfoComment, prevQuickInfoComment, prevQuickInfoLines, prevQuickInfoEndLine;
64
64
  var _b, _c;
65
65
  return __generator(this, function (_d) {
66
66
  switch (_d.label) {
67
67
  case 0:
68
68
  multilineEnabled = localStorage.getItem("shareable-twoslash-comments/enable-multiline-comments") === "true";
69
+ truncationDisabled = localStorage.getItem("shareable-twoslash-comments/disable-truncation") === "true";
69
70
  model = sandbox.getModel();
70
71
  return [4 /*yield*/, sandbox.getWorkerProcess()];
71
72
  case 1:
@@ -97,7 +98,7 @@ define(function () { 'use strict';
97
98
  quickInfoString = (_c = (_b = quickInfo === null || quickInfo === void 0 ? void 0 : quickInfo.displayParts) === null || _b === void 0 ? void 0 : _b.map(function (d) { return d.text; }).join("")) !== null && _c !== void 0 ? _c : "";
98
99
  quickInfoComment = "".concat(match[0], " ").concat(multilineEnabled
99
100
  ? quickInfoString.replace(/\r?\n/g, model.getEOL() + commentPrefix)
100
- : quickInfoString.replace(/\r?\n\s*/g, " "));
101
+ : truncate(quickInfoString.replace(/\r?\n\s*/g, " "), truncationDisabled ? Number.POSITIVE_INFINITY : 100));
101
102
  prevQuickInfoComment = getPreviousQuickInfoComment({
102
103
  model: model,
103
104
  lineNumber: caretPos.lineNumber,
@@ -152,6 +153,9 @@ define(function () { 'use strict';
152
153
  }, delay);
153
154
  };
154
155
  };
156
+ var truncate = function (str, maxLength) {
157
+ return str.length > maxLength ? str.slice(0, maxLength) + "…" : str;
158
+ };
155
159
  //# sourceMappingURL=utils.js.map
156
160
 
157
161
  var debouncedFillTwoSlashQueries = debounce(fillTwoSlashQueries, 600);
@@ -171,6 +175,12 @@ define(function () { 'use strict';
171
175
  display: "Enable multiline comments",
172
176
  onchange: function () { return fillTwoSlashQueries(sandbox); },
173
177
  },
178
+ {
179
+ blurb: "Prevent truncation of single line comments. Otherwise, they will be truncated to 100 characters.",
180
+ flag: "shareable-twoslash-comments/disable-truncation",
181
+ display: "Disable truncation",
182
+ onchange: function () { return fillTwoSlashQueries(sandbox); },
183
+ },
174
184
  ], {
175
185
  style: "separated",
176
186
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareable-twoslash-comments",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
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",