ext-hardwrap-9d986fae.js.map 7.4 KB

1
  1. {"version":3,"file":"ext-hardwrap-9d986fae.js","sources":["../../node_modules/ace-builds/src-noconflict/ext-hardwrap.js"],"sourcesContent":["ace.define(\"ace/ext/hardwrap\",[\"require\",\"exports\",\"module\",\"ace/range\",\"ace/editor\",\"ace/config\"], function(require, exports, module){\"use strict\";\nvar Range = require(\"../range\").Range;\nfunction hardWrap(editor, options) {\n var max = options.column || editor.getOption(\"printMarginColumn\");\n var allowMerge = options.allowMerge != false;\n var row = Math.min(options.startRow, options.endRow);\n var endRow = Math.max(options.startRow, options.endRow);\n var session = editor.session;\n while (row <= endRow) {\n var line = session.getLine(row);\n if (line.length > max) {\n var space = findSpace(line, max, 5);\n if (space) {\n var indentation = /^\\s*/.exec(line)[0];\n session.replace(new Range(row, space.start, row, space.end), \"\\n\" + indentation);\n }\n endRow++;\n }\n else if (allowMerge && /\\S/.test(line) && row != endRow) {\n var nextLine = session.getLine(row + 1);\n if (nextLine && /\\S/.test(nextLine)) {\n var trimmedLine = line.replace(/\\s+$/, \"\");\n var trimmedNextLine = nextLine.replace(/^\\s+/, \"\");\n var mergedLine = trimmedLine + \" \" + trimmedNextLine;\n var space = findSpace(mergedLine, max, 5);\n if (space && space.start > trimmedLine.length || mergedLine.length < max) {\n var replaceRange = new Range(row, trimmedLine.length, row + 1, nextLine.length - trimmedNextLine.length);\n session.replace(replaceRange, \" \");\n row--;\n endRow--;\n }\n else if (trimmedLine.length < line.length) {\n session.remove(new Range(row, trimmedLine.length, row, line.length));\n }\n }\n }\n row++;\n }\n function findSpace(line, max, min) {\n if (line.length < max)\n return;\n var before = line.slice(0, max);\n var after = line.slice(max);\n var spaceAfter = /^(?:(\\s+)|(\\S+)(\\s+))/.exec(after);\n var spaceBefore = /(?:(\\s+)|(\\s+)(\\S+))$/.exec(before);\n var start = 0;\n var end = 0;\n if (spaceBefore && !spaceBefore[2]) {\n start = max - spaceBefore[1].length;\n end = max;\n }\n if (spaceAfter && !spaceAfter[2]) {\n if (!start)\n start = max;\n end = max + spaceAfter[1].length;\n }\n if (start) {\n return {\n start: start,\n end: end\n };\n }\n if (spaceBefore && spaceBefore[2] && spaceBefore.index > min) {\n return {\n start: spaceBefore.index,\n end: spaceBefore.index + spaceBefore[2].length\n };\n }\n if (spaceAfter && spaceAfter[2]) {\n start = max + spaceAfter[2].length;\n return {\n start: start,\n end: start + spaceAfter[3].length\n };\n }\n }\n}\nfunction wrapAfterInput(e) {\n if (e.command.name == \"insertstring\" && /\\S/.test(e.args)) {\n var editor = e.editor;\n var cursor = editor.selection.cursor;\n if (cursor.column <= editor.renderer.$printMarginColumn)\n return;\n var lastDelta = editor.session.$undoManager.$lastDelta;\n hardWrap(editor, {\n startRow: cursor.row, endRow: cursor.row,\n allowMerge: false\n });\n if (lastDelta != editor.session.$undoManager.$lastDelta)\n editor.session.markUndoGroup();\n }\n}\nvar Editor = require(\"../editor\").Editor;\nrequire(\"../config\").defineOptions(Editor.prototype, \"editor\", {\n hardWrap: {\n set: function (val) {\n if (val) {\n this.commands.on(\"afterExec\", wrapAfterInput);\n }\n else {\n this.commands.off(\"afterExec\", wrapAfterInput);\n }\n },\n value: false\n }\n});\nexports.hardWrap = hardWrap;\n\n}); (function() {\n ace.require([\"ace/ext/hardwrap\"], function(m) {\n if (typeof module == \"object\" && typeof exports == \"object\" && module) {\n module.exports = m;\n }\n });\n })();\n "],"names":["require","exports","module","Range","hardWrap","editor","options","max","allowMerge","row","endRow","session","line","space","findSpace","indentation","nextLine","trimmedLine","trimmedNextLine","mergedLine","replaceRange","min","before","after","spaceAfter","spaceBefore","start","end","wrapAfterInput","e","cursor","lastDelta","Editor","val","m"],"mappings":"gaAAA,IAAI,OAAO,mBAAmB,CAAC,UAAU,UAAU,SAAS,YAAY,aAAa,YAAY,EAAG,SAASA,EAASC,EAASC,EAAO,CACtI,IAAIC,EAAQH,EAAQ,UAAU,EAAE,MAChC,SAASI,EAASC,EAAQC,EAAS,CAM/B,QALIC,EAAMD,E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