1 |
- {"version":3,"file":"ext-whitespace-11f4bc8c.js","sources":["../../node_modules/ace-builds/src-noconflict/ext-whitespace.js"],"sourcesContent":["ace.define(\"ace/ext/whitespace\",[\"require\",\"exports\",\"module\",\"ace/lib/lang\"], function(require, exports, module){\"use strict\";\nvar lang = require(\"../lib/lang\");\nexports.$detectIndentation = function (lines, fallback) {\n var stats = [];\n var changes = [];\n var tabIndents = 0;\n var prevSpaces = 0;\n var max = Math.min(lines.length, 1000);\n for (var i = 0; i < max; i++) {\n var line = lines[i];\n if (!/^\\s*[^*+\\-\\s]/.test(line))\n continue;\n if (line[0] == \"\\t\") {\n tabIndents++;\n prevSpaces = -Number.MAX_VALUE;\n }\n else {\n var spaces = line.match(/^ */)[0].length;\n if (spaces && line[spaces] != \"\\t\") {\n var diff = spaces - prevSpaces;\n if (diff > 0 && !(prevSpaces % diff) && !(spaces % diff))\n changes[diff] = (changes[diff] || 0) + 1;\n stats[spaces] = (stats[spaces] || 0) + 1;\n }\n prevSpaces = spaces;\n }\n while (i < max && line[line.length - 1] == \"\\\\\")\n line = lines[i++];\n }\n function getScore(indent) {\n var score = 0;\n for (var i = indent; i < stats.length; i += indent)\n score += stats[i] || 0;\n return score;\n }\n var changesTotal = changes.reduce(function (a, b) { return a + b; }, 0);\n var first = { score: 0, length: 0 };\n var spaceIndents = 0;\n for (var i = 1; i < 12; i++) {\n var score = getScore(i);\n if (i == 1) {\n spaceIndents = score;\n score = stats[1] ? 0.9 : 0.8;\n if (!stats.length)\n score = 0;\n }\n else\n score /= spaceIndents;\n if (changes[i])\n score += changes[i] / changesTotal;\n if (score > first.score)\n first = { score: score, length: i };\n }\n if (first.score && first.score > 1.4)\n var tabLength = first.length;\n if (tabIndents > spaceIndents + 1) {\n if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8)\n tabLength = undefined;\n return { ch: \"\\t\", length: tabLength };\n }\n if (spaceIndents > tabIndents + 1)\n return { ch: \" \", length: tabLength };\n};\nexports.detectIndentation = function (session) {\n var lines = session.getLines(0, 1000);\n var indent = exports.$detectIndentation(lines) || {};\n if (indent.ch)\n session.setUseSoftTabs(indent.ch == \" \");\n if (indent.length)\n session.setTabSize(indent.length);\n return indent;\n};\nexports.trimTrailingSpace = function (session, options) {\n var doc = session.getDocument();\n var lines = doc.getAllLines();\n var min = options && options.trimEmpty ? -1 : 0;\n var cursors = [], ci = -1;\n if (options && options.keepCursorPosition) {\n if (session.selection.rangeCount) {\n session.selection.rangeList.ranges.forEach(function (x, i, ranges) {\n var next = ranges[i + 1];\n if (next && next.cursor.row == x.cursor.row)\n return;\n cursors.push(x.cursor);\n });\n }\n else {\n cursors.push(session.selection.getCursor());\n }\n ci = 0;\n }\n var cursorRow = cursors[ci] && cursors[ci].row;\n for (var i = 0, l = lines.length; i < l; i++) {\n var line = lines[i];\n var index = line.search(/\\s+$/);\n if (i == cursorRow) {\n if (index < cursors[ci].column && index > min)\n index = cursors[ci].column;\n ci++;\n cursorRow = cursors[ci] ? cursors[ci].row : -1;\n }\n if (index > min)\n doc.removeInLine(i, index, line.length);\n }\n};\nexports.convertIndentation = function (session, ch, len) {\n var oldCh = session.getTabString()[0];\n var oldLen = session.getTabSize();\n if (!len)\n len = oldLen;\n if (!ch)\n ch = oldCh;\n var tab = ch == \"\\t\" ? ch : lang.stringRepeat(ch, len);\n var doc = session.doc;\n var lines = doc.getAllLines();\n var cache = {};\n var spaceCache = {};\n for (var i = 0, l = lines.length; i < l; i++) {\n var line = lines[i];\n var match = line.match(/^\\s*/)[0];\n if (match) {\n var w = session.$getStringScreenWidth(match)[0];\n var tabCount = Math.floor(w / oldLen);\n var reminder = w % oldLen;\n var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount));\n toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(\" \", reminder));\n if (toInsert != match) {\n doc.removeInLine(i, 0, match.length);\n doc.insertInLine({ row: i, column: 0 }, toInsert);\n }\n }\n }\n session.setTabSize(len);\n session.setUseSoftTabs(ch == \" \");\n};\nexports.$parseStringArg = function (text) {\n var indent = {};\n if (/t/.test(text))\n indent.ch = \"\\t\";\n else if (/s/.test(text))\n indent.ch = \" \";\n var m = text.match(/\\d+/);\n if (m)\n indent.length = parseInt(m[0], 10);\n return indent;\n};\nexports.$parseArg = function (arg) {\n if (!arg)\n return {};\n if (typeof arg == \"string\")\n return exports.$parseStringArg(arg);\n if (typeof arg.text == \"string\")\n return exports.$parseStringArg(arg.text);\n return arg;\n};\nexports.commands = [{\n name: \"detectIndentation\",\n description: \"Detect indentation from content\",\n exec: function (editor) {\n exports.detectIndentation(editor.session);\n }\n }, {\n name: \"trimTrailingSpace\",\n description: \"Trim trailing whitespace\",\n exec: function (editor, args) {\n exports.trimTrailingSpace(editor.session, args);\n }\n }, {\n name: \"convertIndentation\",\n description: \"Convert indentation to ...\",\n exec: function (editor, arg) {\n var indent = exports.$parseArg(arg);\n exports.convertIndentation(editor.session, indent.ch, indent.length);\n }\n }, {\n name: \"setIndentation\",\n description: \"Set indentation\",\n exec: function (editor, arg) {\n var indent = exports.$parseArg(arg);\n indent.length && editor.session.setTabSize(indent.length);\n indent.ch && editor.session.setUseSoftTabs(indent.ch == \" \");\n }\n }];\n\n}); (function() {\n ace.require([\"ace/ext/whitespace\"], function(m) {\n if (typeof module == \"object\" && typeof exports == \"object\" && module) {\n module.exports = m;\n }\n });\n })();\n "],"names":["require","exports","module","lang","lines","fallback","stats","changes","tabIndents","prevSpaces","max","i","line","spaces","diff","getScore","indent","score","changesTotal","a","b","first","spaceIndents","tabLength","session","options","doc","min","cursors","ci","x","ranges","next","cursorRow","l","index","ch","len","oldCh","oldLen","tab","cache","spaceCache","match","w","tabCount","reminder","toInsert","text","m","arg","editor","args"],"mappings":"gaAAA,IAAI,OAAO,qBAAqB,CAAC,UAAU,UAAU,SAAS,cAAc,EAAG,SAASA,EAASC,EAASC,EAAO,CACjH,IAAIC,EAAOH,EAAQ,aAAa,EAChCC,EAAQ,mBAAqB,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