// CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(Ze){"use strict";var Ge=[{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"",type:"keyToKey",toKeys:"x",context:"normal"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"",type:"idle",context:"normal"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r",type:"action",action:"replace",isEdit:!0},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],Ye=Ge.length,et=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],tt=Ze.Pos;Ze.Vim=function(){function e(e,t){var r,n;this==Ze.keyMap.vim&&(Ze.rmClass(e.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==e.getOption("inputStyle")&&null!=document.body.style.caretColor&&(a(r=e),r.off("cursorActivity",i),r.state.fatCursorMarks=null,e.getInputField().style.caretColor="")),t&&t.attach==o||((n=e).setOption("disableInput",!1),n.off("cursorActivity",Ue),Ze.off(n.getInputField(),"paste",c(n)),n.state.vim=null)}function o(e,t){var r,n;this==Ze.keyMap.vim&&(Ze.addClass(e.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==e.getOption("inputStyle")&&null!=document.body.style.caretColor&&((r=e).state.fatCursorMarks=[],i(r),r.on("cursorActivity",i),e.getInputField().style.caretColor="transparent")),t&&t.attach==o||((n=e).setOption("disableInput",!0),n.setOption("showCursorWhenSelecting",!1),Ze.signal(n,"vim-mode-change",{mode:"normal"}),n.on("cursorActivity",Ue),E(n),Ze.on(n.getInputField(),"paste",c(n)))}function i(e){if(e.state.fatCursorMarks){a(e);for(var t=e.listSelections(),r=[],n=0;n"}(e);if(!r)return!1;var n=Ze.Vim.findKey(t,r);return"function"==typeof n&&Ze.signal(t,"vim-keypress",r),n}}Ze.defineOption("vimMode",!1,function(e,t,r){t&&"vim"!=e.getOption("keyMap")?e.setOption("keyMap","vim"):!t&&r!=Ze.Init&&/^vim/.test(e.getOption("keyMap"))&&e.setOption("keyMap","default")});var s={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},l={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"};function c(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(q(e.getCursor(),0,1)),U.enterInsertMode(e,{},t))}),t.onPasteFn}var u=/[\d]/,m=[Ze.isWordChar,function(e){return e&&!Ze.isWordChar(e)&&!/\s/.test(e)}],g=[function(e){return/\S/.test(e)}];function r(e,t){for(var r=[],n=e;n"]),d=[].concat(n,h,p,["-",'"',".",":","_","/"]);function v(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function y(e){return/^[a-z]$/.test(e)}function k(e){return/^[A-Z]$/.test(e)}function B(e){return/^\s*$/.test(e)}function C(e){return-1!=".?!".indexOf(e)}function w(e,t){for(var r=0;r"==l&&(P(s),c.visualMode?le(s):c.insertMode&&We(s),1)}return!1===(e=(c.insertMode?function(){if(u())return!0;for(var e=c.inputState.keyBuffer=c.inputState.keyBuffer+l,t=1==l.length,r=F.matchCommand(e,Ge,c.inputState,"insert");1|<\w+>|./.exec(e),l=t[0],e=e.substring(t.index+l.length),Ze.Vim.handleKey(s,l,"mapping")}(e.toKeys):F.processCommand(s,c,e)}catch(e){throw s.state.vim=void 0,E(s),Ze.Vim.suppressErrorLogging||console.log(e),e}return!0})}},handleEx:function(e,t){Fe.processCommand(e,t)},defineMotion:function(e,t){W[e]=t},defineAction:function(e,t){U[e]=t},defineOperator:function(e,t){D[e]=t},mapCommand:function(e,t,r,n,o){var i={keys:e,type:t};for(var a in i[t]=r,i[t+"Args"]=n,o)i[a]=o[a];Ve(i)},_mapCommand:Ve,defineRegister:function(e,t){var r=K.registerController.registers;if(!e||1!=e.length)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,d.push(e)},exitVisualMode:le,exitInsertMode:We};function N(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function P(e,t){e.state.vim.inputState=new N,Ze.signal(e,"vim-command-done",t)}function _(e,t,r){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!r}function j(e){this.registers=e,this.unnamedRegister=e['"']=new _,e["."]=new _,e[":"]=new _,e["/"]=new _}function H(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}N.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},N.prototype.getRepeat=function(){var e=0;return(0=r.length?(this.iterator=r.length,this.initialPrefix):o<0?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);-1"!=t.slice(-11))return e==t?"full":0==t.indexOf(e)&&"partial";var r=t.length-11,n=e.slice(0,r),o=t.slice(0,r);return n==o&&e.length>r?"full":0==o.indexOf(n)&&"partial"}}(e,l.keys))||("partial"==o&&i.push(l),"full"==o&&a.push(l))}return{partial:i.length&&i,full:a.length&&a}}(e,t,n,r);if(!o.full&&!o.partial)return{type:"none"};if(!o.full&&o.partial)return{type:"partial"};for(var i=0;i"==s.keys.slice(-11)){var l=function(e){var t=/^.*(<[^>]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(1":r="\n";break;case"":r=" ";break;default:r=""}return r}(e);if(!l)return{type:"none"};r.selectedCharacter=l}return{type:"full",command:s}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r)}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=$(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator){if(n.operator==r.operator)return n.motion="expandToLine",n.motionArgs={linewise:!0},void this.evalInput(e,t);P(e)}n.operator=r.operator,n.operatorArgs=$(r.operatorArgs),r.exitVisualBlock&&(t.visualBlock=!1,ae(e)),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,o=$(r.operatorMotionArgs);o&&n&&o.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,o=n.getRepeat(),i=!!o,a=$(r.actionArgs)||{};n.selectedCharacter&&(a.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),a.repeat=o||1,a.repeatIsExplicit=i,a.registerName=n.registerName,P(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),U[r.action](e,a,t)},processSearch:function(s,n,o){if(s.getSearchCursor){var l=o.searchArgs.forward,e=o.searchArgs.wholeWordOnly;Ce(s).setReversed(!l);var t=l?"/":"?",i=Ce(s).getQuery(),c=s.getScrollInfo();switch(o.searchArgs.querySrc){case"prompt":var r=K.macroModeState;r.isPlaying?p(h=r.replaySearchQueries.shift(),!0,!1):Re(s,{onClose:function(e){s.scrollTo(c.left,c.top),p(e,!0,!0);var t=K.macroModeState;t.isRecording&&function(e,t){if(e.isPlaying)return;var r=e.latestRegister,n=K.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}(t,e)},prefix:t,desc:Te,onKeyUp:function(e,t,r){var n,o,i,a=Ze.keyName(e);"Up"==a||"Down"==a?(n="Up"==a,o=e.target?e.target.selectionEnd:0,r(t=K.searchHistoryController.nextMatch(t,n)||""),o&&e.target&&(e.target.selectionEnd=e.target.selectionStart=Math.min(o,e.target.value.length))):"Left"!=a&&"Right"!=a&&"Ctrl"!=a&&"Alt"!=a&&"Shift"!=a&&K.searchHistoryController.reset();try{i=Ee(s,t,!0,!0)}catch(e){}i?s.scrollIntoView(Ie(s,!l,i),30):(Ke(s),s.scrollTo(c.left,c.top))},onKeyDown:function(e,t,r){var n=Ze.keyName(e);"Esc"==n||"Ctrl-C"==n||"Ctrl-["==n||"Backspace"==n&&""==t?(K.searchHistoryController.pushInput(t),K.searchHistoryController.reset(),Ee(s,i),Ke(s),s.scrollTo(c.left,c.top),Ze.e_stop(e),P(s),r(),s.focus()):"Up"==n||"Down"==n?Ze.e_stop(e):"Ctrl-U"==n&&(Ze.e_stop(e),r(""))}});break;case"wordUnderCursor":var a=ue(s,!1,0,!1,!0),u=!0;if(a||(a=ue(s,!1,0,!1,!1),u=!1),!a)return;var h=s.getLine(a.start.line).substring(a.start.ch,a.end.ch);h=u&&e?"\\b"+h+"\\b":h.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1"),K.jumpList.cachedCursor=s.getCursor(),s.setCursor(a.start),p(h,!0,!1)}}function p(t,e,r){K.searchHistoryController.pushInput(t),K.searchHistoryController.reset();try{Ee(s,t,e,r)}catch(e){return Le(s,"Invalid regex: "+t),void P(s)}F.processMotion(s,n,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:o.searchArgs.toJumplist}})}},processEx:function(a,e,t){function r(e){K.exCommandHistoryController.pushInput(e),K.exCommandHistoryController.reset(),Fe.processCommand(a,e)}function n(e,t,r){var n,o,i=Ze.keyName(e);("Esc"==i||"Ctrl-C"==i||"Ctrl-["==i||"Backspace"==i&&""==t)&&(K.exCommandHistoryController.pushInput(t),K.exCommandHistoryController.reset(),Ze.e_stop(e),P(a),r(),a.focus()),"Up"==i||"Down"==i?(Ze.e_stop(e),n="Up"==i,o=e.target?e.target.selectionEnd:0,r(t=K.exCommandHistoryController.nextMatch(t,n)||""),o&&e.target&&(e.target.selectionEnd=e.target.selectionStart=Math.min(o,e.target.value.length))):"Ctrl-U"==i?(Ze.e_stop(e),r("")):"Left"!=i&&"Right"!=i&&"Ctrl"!=i&&"Alt"!=i&&"Shift"!=i&&K.exCommandHistoryController.reset()}"keyToEx"==t.type?Fe.processCommand(a,t.exArgs.input):e.visualMode?Re(a,{onClose:r,prefix:":",value:"'<,'>",onKeyDown:n,selectValueOnOpen:!1}):Re(a,{onClose:r,prefix:":",onKeyDown:n})},evalInput:function(e,t){var r,n,o,i,a,s,l,c,u,h,p,f,d=t.inputState,m=d.motion,g=d.motionArgs||{},v=d.operator,y=d.operatorArgs||{},k=d.registerName,C=t.sel,w=z(t.visualMode?J(e,C.head):e.getCursor("head")),x=z(t.visualMode?J(e,C.anchor):e.getCursor("anchor")),M=z(w),S=z(x);if(v&&this.recordLastEdit(t,d),0<(n=void 0!==d.repeatOverride?d.repeatOverride:d.getRepeat())&&g.explicitRepeat?g.repeatIsExplicit=!0:(g.noRepeat||!g.explicitRepeat&&0===n)&&(n=1,g.repeatIsExplicit=!1),d.selectedCharacter&&(g.selectedCharacter=y.selectedCharacter=d.selectedCharacter),g.repeat=n,P(e),m){var A,b,L=W[m](e,w,g,t,d);if(t.lastMotion=W[m],!L)return;g.toJumplist&&((b=(A=K.jumpList).cachedCursor)?(he(e,b,L),delete A.cachedCursor):he(e,w,L)),s=(s=L instanceof Array?(r=L[0],L[1]):L)||z(w),t.visualMode?(t.visualBlock&&s.ch===1/0||(s=J(e,s)),r=(r=r&&J(e,r))||S,C.anchor=r,C.head=s,ae(e),ve(e,t,"<",Z(r,s)?r:s),ve(e,t,">",Z(r,s)?s:r)):v||(s=J(e,s),e.setCursor(s.line,s.ch))}if(v){if(y.lastSel?(r=S,o=y.lastSel,i=Math.abs(o.head.line-o.anchor.line),a=Math.abs(o.head.ch-o.anchor.ch),s=o.visualLine?tt(S.line+i,S.ch):o.visualBlock?tt(S.line+i,S.ch+a):o.head.line==o.anchor.line?tt(S.line,S.ch+a):tt(S.line+i,S.ch),t.visualMode=!0,t.visualLine=o.visualLine,t.visualBlock=o.visualBlock,C=t.sel={anchor:r,head:s},ae(e)):t.visualMode&&(y.lastSel={anchor:z(C.anchor),head:z(C.head),visualBlock:t.visualBlock,visualLine:t.visualLine}),t.visualMode){if(h=G(C.head,C.anchor),p=Y(C.head,C.anchor),l=t.visualLine||y.linewise,E=se(e,{anchor:h,head:p},c=t.visualBlock?"block":l?"line":"char"),l){var T=E.ranges;if("block"==c)for(var R=0;Rs:u.line=t.line.length){if(t.ln+=t.dir,!v(e,t.ln))return t.line=null,t.ln=null,void(t.pos=null);t.line=e.getLine(t.ln),t.pos=0"===i?/[(){}[\]<>]/:/[(){}[\]]/;return e.findMatchingBracket(tt(o,i),{bracketRegex:l}).to}return n},moveToStartOfLine:function(e,t){return tt(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var n=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(n=r.repeat-e.getOption("firstLineNumber")),tt(n,ce(e.getLine(n)))},textObjectManipulation:function(e,t,r,n){var o=r.selectedCharacter;"b"==o?o="(":"B"==o&&(o="{");var i=!r.textObjectInner;if({"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"}[o])s=function(e,t,r,n){var o,i,a=t,s={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[r],l={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[r],c=e.getLine(a.line).charAt(a.ch)===l?1:0;if(o=e.scanForBracket(tt(a.line,a.ch+c),-1,void 0,{bracketRegex:s}),i=e.scanForBracket(tt(a.line,a.ch+c),1,void 0,{bracketRegex:s}),!o||!i)return{start:a,end:a};{var u;o=o.pos,i=i.pos,(o.line==i.line&&o.ch>i.ch||o.line>i.line)&&(u=o,o=i,i=u)}n?i.ch+=1:o.ch+=1;return{start:o,end:i}}(e,t,o,i);else if({"'":!0,'"':!0,"`":!0}[o])s=function(e,t,r,n){var o,i,a,s,l=z(t),c=e.getLine(l.line).split(""),u=c.indexOf(r);l.che.lastLine()&&t.linewise&&!l?e.replaceRange("",s,h):e.replaceRange("",u,h),t.linewise&&(l||(e.setCursor(s),Ze.commands.newlineAndIndent(e)),u.ch=Number.MAX_VALUE),u);K.registerController.pushText(t.registerName,"change",n,t.linewise,1c.top?(l.line+=(s-c.top)/o,l.line=Math.ceil(l.line),e.setCursor(l),c=e.charCoords(l,"local"),e.scrollTo(null,c.top)):e.scrollTo(null,s):(u=s+e.getScrollInfo().clientHeight)|<\w+>|./.exec(h),l=s[0],h=h.substring(s.index+l.length),Ze.Vim.handleKey(e,l,"macro"),t.insertMode&&(u=o.insertModeChanges[a++].changes,K.macroModeState.lastInsertModeChanges.changes=u,Xe(e,u,1),We(e))}r.isPlaying=!1}(e,r,i,n)},enterMacroRecordMode:function(e,t){var r=K.macroModeState,n=t.selectedCharacter;K.registerController.isValidRegister(n)&&r.enterMacroRecordMode(e,n)},toggleOverwrite:function(e){e.state.overwrite?(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),Ze.signal(e,"vim-mode-change",{mode:"insert"})):(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),Ze.signal(e,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(e,t,r){if(!e.getOption("readOnly")){r.insertMode=!0,r.insertModeRepeat=t&&t.repeat||1;var n=t?t.insertAt:null,o=r.sel,i=t.head||e.getCursor("head"),a=e.listSelections().length;if("eol"==n)i=tt(i.line,te(e,i.line));else if("bol"==n)i=tt(i.line,0);else if("charAfter"==n)i=q(i,0,1);else if("firstNonBlank"==n)i=W.moveToFirstNonWhiteSpaceCharacter(e,i);else if("startOfSelectedArea"==n){if(!r.visualMode)return;r.visualBlock?(i=tt(Math.min(o.head.line,o.anchor.line),Math.min(o.head.ch,o.anchor.ch)),a=Math.abs(o.head.line-o.anchor.line)+1):i=o.head.line=o.anchor.line?q(o.head,0,1):tt(o.anchor.line,0)}else if("inplace"==n){if(r.visualMode)return}else"lastEdit"==n&&(i=_e(e)||i);e.setOption("disableInput",!1),t&&t.replace?(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),Ze.signal(e,"vim-mode-change",{mode:"replace"})):(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),Ze.signal(e,"vim-mode-change",{mode:"insert"})),K.macroModeState.isPlaying||(e.on("change",De),Ze.on(e.getInputField(),"keydown",Qe)),r.visualMode&&le(e),oe(e,i,a)}},toggleVisualMode:function(e,t,r){var n,o=t.repeat,i=e.getCursor();r.visualMode?r.visualLine^t.linewise||r.visualBlock^t.blockwise?(r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,Ze.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),ae(e)):le(e):(r.visualMode=!0,r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,n=J(e,tt(i.line,i.ch+o-1)),r.sel={anchor:i,head:n},Ze.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),ae(e),ve(e,r,"<",G(i,n)),ve(e,r,">",Y(i,n)))},reselectLastSelection:function(e,t,r){var n=r.lastSelection;if(r.visualMode&&ie(e,r),n){var o=n.anchorMark.find(),i=n.headMark.find();if(!o||!i)return;r.sel={anchor:o,head:i},r.visualMode=!0,r.visualLine=n.visualLine,r.visualBlock=n.visualBlock,ae(e),ve(e,r,"<",G(o,i)),ve(e,r,">",Y(o,i)),Ze.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var n,o,i;r.visualMode?(o=e.getCursor("anchor"),Z(n=e.getCursor("head"),o)&&(l=n,n=o,o=l),n.ch=te(e,n.line)-1):(i=Math.max(t.repeat,2),o=e.getCursor(),n=J(e,tt(o.line+i-1,1/0)));for(var a=0,s=o.line;sn.lastLine()&&n.replaceRange("\n",tt(I,0)),te(n,I)n.length&&(o=n.length),tt(l.line,o));"\n"==s?(r.visualMode||e.replaceRange("",l,u),(Ze.commands.newlineAndIndentContinueComment||Ze.commands.newlineAndIndent)(e)):(a=(a=e.getRange(l,u)).replace(/[^\n]/g,s),r.visualBlock?(i=new Array(e.getOption("tabSize")+1).join(" "),a=(a=e.getSelection()).replace(/\t/g,i).replace(/[^\n]/g,s).split("\n"),e.replaceSelections(a)):e.replaceRange(a,l,u),r.visualMode?(l=Z(c[0].anchor,c[0].head)?c[0].anchor:c[0].head,e.setCursor(l),le(e,!1)):e.setCursor(q(u,0,-1)))},incrementNumberToken:function(e,t){for(var r,n,o,i,a,s,l,c,u,h,p,f=e.getCursor(),d=e.getLine(f.line),m=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi;null!==(r=m.exec(d))&&(o=(n=r.index)+r[0].length,!(f.cho&&(i.line=o),i.ch=te(e,i.line)),{ranges:[{anchor:a,head:i}],primary:0};if("block"==r){for(var c=Math.min(a.line,i.line),u=Math.min(a.ch,i.ch),h=Math.max(a.line,i.line),p=Math.max(a.ch,i.ch)+1,f=h-c+1,d=i.line==c?0:f-1,m=[],g=0;g=l.length)return null;n?u=g[0]:(u=m[0])(l.charAt(c))||(u=m[1]);for(var h=c,p=c;u(l.charAt(h))&&h'+t+"",{bottom:!0,duration:5e3}):alert(t)}var Te="(Javascript regexp)";function Re(e,t){var r,n,o,i,a,s,l,c,u=(t.prefix||"")+" "+(t.desc||""),h=(r=t.prefix,n=t.desc,o=''+(r||"")+'',n&&(o+=' '+n+""),o);i=e,a=h,s=u,l=t.onClose,c=t,i.openDialog?i.openDialog(a,l,{bottom:!0,value:c.value,onKeyDown:c.onKeyDown,onKeyUp:c.onKeyUp,selectValueOnOpen:!1}):l(prompt(s,""))}function Ee(e,t,r,n){if(t){var o=Ce(e),i=be(t,!!r,!!n);if(i)return Be(e,i),function(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var r=["global","multiline","ignoreCase","source"],n=0;n@~])/);return r.commandName=n?n[1]:t.match(/.*/)[0],r},parseLineSpec_:function(e,t){var r=t.match(/^(\d+)/);if(r)return parseInt(r[1],10)-1;switch(t.next()){case".":return this.parseLineSpecOffset_(t,e.getCursor().line);case"$":return this.parseLineSpecOffset_(t,e.lastLine());case"'":var n=t.next(),o=Pe(e,e.state.vim,n);if(!o)throw new Error("Mark not set");return this.parseLineSpecOffset_(t,o.line);case"-":case"+":return t.backUp(1),this.parseLineSpecOffset_(t,e.getCursor().line);default:return void t.backUp(1)}},parseLineSpecOffset_:function(e,t){var r,n=e.match(/^([+-])?(\d+)/);return n&&(r=parseInt(n[2],10),"-"==n[1]?t-=r:t+=r),t},parseCommandArgs_:function(e,t,r){var n,o;e.eol()||(t.argString=e.match(/.*/)[0],n=r.argDelimiter||/\s+/,(o=re(t.argString).split(n)).length&&o[0]&&(t.args=o))},matchCommand_:function(e){for(var t=e.length;0
";if(r)for(var r=r.join(""),i=0;i")}else for(var a in n){var s=n[a].toString();s.length&&(o+='"'+a+" "+s+"
")}Le(e,o)},sort:function(e,i){var a,s,l,c,u;var t=function(){if(i.argString){var e=new Ze.StringStream(i.argString);if(e.eat("!")&&(a=!0),e.eol())return;if(!e.eatSpace())return"Invalid arguments";var t=e.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!t&&!e.eol())return"Invalid arguments";if(t[1]){s=-1!=t[1].indexOf("i"),l=-1!=t[1].indexOf("u");var r=-1!=t[1].indexOf("d")||-1!=t[1].indexOf("n")&&1,n=-1!=t[1].indexOf("x")&&1,o=-1!=t[1].indexOf("o")&&1;if(1")}n?(l=0,(c=function(){var e;l"+r+" (y/n/a/q/l)",onKeyDown:function(e,t,r){switch(Ze.e_stop(e),Ze.keyName(e)){case"Y":p(),f();break;case"N":f();break;case"A":var n=l;l=void 0,o.operation(h),l=n;break;case"L":p();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":d(r)}return c&&d(r),!0}})}(t,d,m,s,l,u,a,f,e.callback)):Le(t,"No previous substitute regular expression")},redo:Ze.commands.redo,undo:Ze.commands.undo,write:function(e){Ze.commands.save?Ze.commands.save(e):e.save&&e.save()},nohlsearch:function(e){Ke(e)},yank:function(e){var t=z(e.getCursor()).line,r=e.getLine(t);K.registerController.pushText("0","yank",r,!0,!0)},delmarks:function(e,t){if(t.argString&&re(t.argString))for(var r=e.state.vim,n=new Ze.StringStream(re(t.argString));!n.eol();){n.eatSpace();var o=n.pos;if(!n.match(/[a-zA-Z]/,!1))return void Le(e,"Invalid argument: "+t.argString.substring(o));var i=n.next();if(n.match("-",!0)){if(!n.match(/[a-zA-Z]/,!1))return void Le(e,"Invalid argument: "+t.argString.substring(o));var a=i,s=n.next();if(!(y(a)&&y(s)||k(a)&&k(s)))return void Le(e,"Invalid argument: "+a+"-");var l=a.charCodeAt(0),c=s.charCodeAt(0);if(c<=l)return void Le(e,"Invalid argument: "+t.argString.substring(o));for(var u=0;u<=c-l;u++){var h=String.fromCharCode(l+u);delete r.marks[h]}}else delete r.marks[i]}else Le(e,"Argument required")}},Fe=new je;function We(e){var t=e.state.vim,r=K.macroModeState,n=K.registerController.getRegister("."),o=r.isPlaying,i=r.lastInsertModeChanges;o||(e.off("change",De),Ze.off(e.getInputField(),"keydown",Qe)),!o&&1",Y(n,r))):t.insertMode||(t.lastHPos=e.getCursor().ch)}}(e,t);t.visualMode&&Je(e)}function Je(e){var t,r="cm-animate-fat-cursor",n=e.state.vim,o=J(e,z(n.sel.head)),i=q(o,0,1);$e(n),o.ch==e.getLine(o.line).length?((t=document.createElement("span")).textContent=" ",t.className=r,n.fakeCursorBookmark=e.setBookmark(o,{widget:t})):n.fakeCursor=e.markText(o,i,{className:r})}function $e(e){e.fakeCursor&&(e.fakeCursor.clear(),e.fakeCursor=null),e.fakeCursorBookmark&&(e.fakeCursorBookmark.clear(),e.fakeCursorBookmark=null)}function qe(e){this.keyName=e}function Qe(e){var t=K.macroModeState.lastInsertModeChanges,r=Ze.keyName(e);r&&(-1==r.indexOf("Delete")&&-1==r.indexOf("Backspace")||Ze.lookupKey(r,"vim-insert",function(){return t.maybeReset&&(t.changes=[],t.maybeReset=!1),t.changes.push(new qe(r)),!0}))}function ze(r,n,e,t){var o=K.macroModeState;o.isPlaying=!0;var i=!!n.lastEditActionCommand,a=n.inputState;function s(){i?F.processAction(r,n,n.lastEditActionCommand):F.evalInput(r,n)}function l(e){var t;0