1 |
- {"version":3,"file":"ext-code_lens-cfeb1580.js","sources":["../../node_modules/ace-builds/src-noconflict/ext-code_lens.js"],"sourcesContent":["ace.define(\"ace/ext/code_lens\",[\"require\",\"exports\",\"module\",\"ace/line_widgets\",\"ace/lib/event\",\"ace/lib/lang\",\"ace/lib/dom\",\"ace/editor\",\"ace/config\"], function(require, exports, module){\"use strict\";\nvar LineWidgets = require(\"../line_widgets\").LineWidgets;\nvar event = require(\"../lib/event\");\nvar lang = require(\"../lib/lang\");\nvar dom = require(\"../lib/dom\");\nfunction clearLensElements(renderer) {\n var textLayer = renderer.$textLayer;\n var lensElements = textLayer.$lenses;\n if (lensElements)\n lensElements.forEach(function (el) { el.remove(); });\n textLayer.$lenses = null;\n}\nfunction renderWidgets(changes, renderer) {\n var changed = changes & renderer.CHANGE_LINES\n || changes & renderer.CHANGE_FULL\n || changes & renderer.CHANGE_SCROLL\n || changes & renderer.CHANGE_TEXT;\n if (!changed)\n return;\n var session = renderer.session;\n var lineWidgets = renderer.session.lineWidgets;\n var textLayer = renderer.$textLayer;\n var lensElements = textLayer.$lenses;\n if (!lineWidgets) {\n if (lensElements)\n clearLensElements(renderer);\n return;\n }\n var textCells = renderer.$textLayer.$lines.cells;\n var config = renderer.layerConfig;\n var padding = renderer.$padding;\n if (!lensElements)\n lensElements = textLayer.$lenses = [];\n var index = 0;\n for (var i = 0; i < textCells.length; i++) {\n var row = textCells[i].row;\n var widget = lineWidgets[row];\n var lenses = widget && widget.lenses;\n if (!lenses || !lenses.length)\n continue;\n var lensContainer = lensElements[index];\n if (!lensContainer) {\n lensContainer = lensElements[index]\n = dom.buildDom([\"div\", { class: \"ace_codeLens\" }], renderer.container);\n }\n lensContainer.style.height = config.lineHeight + \"px\";\n index++;\n for (var j = 0; j < lenses.length; j++) {\n var el = lensContainer.childNodes[2 * j];\n if (!el) {\n if (j != 0)\n lensContainer.appendChild(dom.createTextNode(\"\\xa0|\\xa0\"));\n el = dom.buildDom([\"a\"], lensContainer);\n }\n el.textContent = lenses[j].title;\n el.lensCommand = lenses[j];\n }\n while (lensContainer.childNodes.length > 2 * j - 1)\n lensContainer.lastChild.remove();\n var top = renderer.$cursorLayer.getPixelPosition({\n row: row,\n column: 0\n }, true).top - config.lineHeight * widget.rowsAbove - config.offset;\n lensContainer.style.top = top + \"px\";\n var left = renderer.gutterWidth;\n var indent = session.getLine(row).search(/\\S|$/);\n if (indent == -1)\n indent = 0;\n left += indent * config.characterWidth;\n lensContainer.style.paddingLeft = padding + left + \"px\";\n }\n while (index < lensElements.length)\n lensElements.pop().remove();\n}\nfunction clearCodeLensWidgets(session) {\n if (!session.lineWidgets)\n return;\n var widgetManager = session.widgetManager;\n session.lineWidgets.forEach(function (widget) {\n if (widget && widget.lenses)\n widgetManager.removeLineWidget(widget);\n });\n}\nexports.setLenses = function (session, lenses) {\n var firstRow = Number.MAX_VALUE;\n clearCodeLensWidgets(session);\n lenses && lenses.forEach(function (lens) {\n var row = lens.start.row;\n var column = lens.start.column;\n var widget = session.lineWidgets && session.lineWidgets[row];\n if (!widget || !widget.lenses) {\n widget = session.widgetManager.$registerLineWidget({\n rowCount: 1,\n rowsAbove: 1,\n row: row,\n column: column,\n lenses: []\n });\n }\n widget.lenses.push(lens.command);\n if (row < firstRow)\n firstRow = row;\n });\n session._emit(\"changeFold\", { data: { start: { row: firstRow } } });\n return firstRow;\n};\nfunction attachToEditor(editor) {\n editor.codeLensProviders = [];\n editor.renderer.on(\"afterRender\", renderWidgets);\n if (!editor.$codeLensClickHandler) {\n editor.$codeLensClickHandler = function (e) {\n var command = e.target.lensCommand;\n if (!command)\n return;\n editor.execCommand(command.id, command.arguments);\n editor._emit(\"codeLensClick\", e);\n };\n event.addListener(editor.container, \"click\", editor.$codeLensClickHandler, editor);\n }\n editor.$updateLenses = function () {\n var session = editor.session;\n if (!session)\n return;\n if (!session.widgetManager) {\n session.widgetManager = new LineWidgets(session);\n session.widgetManager.attach(editor);\n }\n var providersToWaitNum = editor.codeLensProviders.length;\n var lenses = [];\n editor.codeLensProviders.forEach(function (provider) {\n provider.provideCodeLenses(session, function (err, payload) {\n if (err)\n return;\n payload.forEach(function (lens) {\n lenses.push(lens);\n });\n providersToWaitNum--;\n if (providersToWaitNum == 0) {\n applyLenses();\n }\n });\n });\n function applyLenses() {\n var cursor = session.selection.cursor;\n var oldRow = session.documentToScreenRow(cursor);\n var scrollTop = session.getScrollTop();\n var firstRow = exports.setLenses(session, lenses);\n var lastDelta = session.$undoManager && session.$undoManager.$lastDelta;\n if (lastDelta && lastDelta.action == \"remove\" && lastDelta.lines.length > 1)\n return;\n var row = session.documentToScreenRow(cursor);\n var lineHeight = editor.renderer.layerConfig.lineHeight;\n var top = session.getScrollTop() + (row - oldRow) * lineHeight;\n if (firstRow == 0 && scrollTop < lineHeight / 4 && scrollTop > -lineHeight / 4) {\n top = -lineHeight;\n }\n session.setScrollTop(top);\n }\n };\n var updateLenses = lang.delayedCall(editor.$updateLenses);\n editor.$updateLensesOnInput = function () {\n updateLenses.delay(250);\n };\n editor.on(\"input\", editor.$updateLensesOnInput);\n}\nfunction detachFromEditor(editor) {\n editor.off(\"input\", editor.$updateLensesOnInput);\n editor.renderer.off(\"afterRender\", renderWidgets);\n if (editor.$codeLensClickHandler)\n editor.container.removeEventListener(\"click\", editor.$codeLensClickHandler);\n}\nexports.registerCodeLensProvider = function (editor, codeLensProvider) {\n editor.setOption(\"enableCodeLens\", true);\n editor.codeLensProviders.push(codeLensProvider);\n editor.$updateLensesOnInput();\n};\nexports.clear = function (session) {\n exports.setLenses(session, null);\n};\nvar Editor = require(\"../editor\").Editor;\nrequire(\"../config\").defineOptions(Editor.prototype, \"editor\", {\n enableCodeLens: {\n set: function (val) {\n if (val) {\n attachToEditor(this);\n }\n else {\n detachFromEditor(this);\n }\n }\n }\n});\ndom.importCssString(\"\\n.ace_codeLens {\\n position: absolute;\\n color: #aaa;\\n font-size: 88%;\\n background: inherit;\\n width: 100%;\\n display: flex;\\n align-items: flex-end;\\n pointer-events: none;\\n}\\n.ace_codeLens > a {\\n cursor: pointer;\\n pointer-events: auto;\\n}\\n.ace_codeLens > a:hover {\\n color: #0000ff;\\n text-decoration: underline;\\n}\\n.ace_dark > .ace_codeLens > a:hover {\\n color: #4e94ce;\\n}\\n\", \"codelense.css\", false);\n\n}); (function() {\n ace.require([\"ace/ext/code_lens\"], function(m) {\n if (typeof module == \"object\" && typeof exports == \"object\" && module) {\n module.exports = m;\n }\n });\n })();\n "],"names":["require","exports","module","LineWidgets","event","lang","dom","clearLensElements","renderer","textLayer","lensElements","el","renderWidgets","changes","changed","session","lineWidgets","textCells","config","padding","index","i","row","widget","lenses","lensContainer","j","top","left","indent","clearCodeLensWidgets","widgetManager","firstRow","lens","column","attachToEditor","editor","e","command","providersToWaitNum","provider","err","payload","applyLenses","cursor","oldRow","scrollTop","lastDelta","lineHeight","updateLenses","detachFromEditor","codeLensProvider","Editor","val","m"],"mappings":"gaAAA,IAAI,OAAO,oBAAoB,CAAC,UAAU,UAAU,SAAS,mBAAmB,gBAAgB,eAAe,cAAc,aAAa,YAAY,EAAG,SAASA,EAASC,EAASC,EAAO,CAC3L,IAAIC,EAAcH,EAAQ,iBAAiB,EAAE,YACzCI,EAAQJ,EAAQ,cAAc,EAC9BK,EAAOL,EAAQ,aAAa,EAC5BM,EAAMN,EAAQ,YAAY,EAC9B,SAASO,EAAkBC,EAAU,CACjC,IAAIC,EAAYD,EAAS,WACrBE,EAAeD,EAAU,QACzBC,GACAA,EAAa,QAAQ,SAAUC,EAAI,CAAEA,EAAG,OAAM,CAAG,CAAE,EACvDF,EAAU,QAAU,IACvB,CACD,SAASG,EAAcC,EAASL,EAAU,CACtC,IAAIM,EAAUD,EAAUL,EAAS,cAC1BK,EAAUL,EAAS,aACnBK,EAAUL,EAAS,eACnBK,EAAUL,EAAS,YAC1B,GAAKM,EAEL,KAAIC,EAAUP,EAAS,QACnBQ,EAAcR,EAAS,QAAQ,YAC/BC,EAAYD,EAAS,WACrBE,EAAeD,EAAU,Q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