monaco-vim
Version:
Vim keybindings for monaco-editor
2 lines • 107 kB
JavaScript
/*! For license information please see monaco-vim.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("monaco-editor/esm/vs/editor/editor.api"),require("monaco-editor/esm/vs/editor/common/commands/shiftCommand")):"function"==typeof define&&define.amd?define(["vs/editor/editor.main","vs/editor/common/commands/shiftCommand"],t):"object"==typeof exports?exports.MonacoVim=t(require("monaco-editor/esm/vs/editor/editor.api"),require("monaco-editor/esm/vs/editor/common/commands/shiftCommand")):e.MonacoVim=t(e.monaco,e[void 0])}(self,((e,t)=>(()=>{"use strict";var n={774:e=>{e.exports=t},135:t=>{t.exports=e}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{StatusBar:()=>N,VimMode:()=>R,initVimMode:()=>K});var a=o(135),s=o(774);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}function f(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}var p={readOnly:65,cursorWidth:20,fontInfo:32},m=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function g(e,t){if(!(this instanceof g))return new g(e,t);this.line=e,this.ch=t}String.prototype.normalize;var v=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};function y(e){return new g(e.lineNumber-1,e.column-1)}function k(e){return new a.Position(e.line+1,e.ch+1)}v.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var n=t==e;else n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){throw"not implemented"},indentation:function(){throw"not implemented"},match:function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var o=function(e){return n?e.toLowerCase():e};if(o(this.string.substr(this.pos,e.length))==o(e))return!1!==t&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var C=function(){return f((function e(t,n,r,o){u(this,e),this.cm=t,this.id=n,this.lineNumber=r+1,this.column=o+1,t.marks[this.id]=this}),[{key:"clear",value:function(){delete this.cm.marks[this.id]}},{key:"find",value:function(){return y(this)}}])}();function w(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!0,r=a.KeyCode[e.keyCode];e.key&&(r=e.key,n=!1);var o=r,i=t;switch(e.keyCode){case a.KeyCode.Shift:case a.KeyCode.Meta:case a.KeyCode.Alt:case a.KeyCode.Ctrl:return o;case a.KeyCode.Escape:i=!0,o="Esc";break;case a.KeyCode.Space:i=!0}return r.startsWith("Key")||r.startsWith("KEY_")?o=r[r.length-1].toLowerCase():r.startsWith("Digit")?o=r.slice(5,6):r.startsWith("Numpad")?o=r.slice(6,7):r.endsWith("Arrow")?(i=!0,o=r.substring(0,r.length-5)):(r.startsWith("US_")||r.startsWith("Bracket")||!o)&&(o=e.browserEvent.key),i||e.altKey||e.ctrlKey||e.metaKey?(e.altKey&&(o="Alt-".concat(o)),e.ctrlKey&&(o="Ctrl-".concat(o)),e.metaKey&&(o="Meta-".concat(o)),e.shiftKey&&(o="Shift-".concat(o))):o=e.key||e.browserEvent.key,1===o.length&&n&&(o="'".concat(o,"'")),o}var S=function(){function e(t){u(this,e),M.call(this),this.editor=t,this.state={keyMap:"vim"},this.marks={},this.$uid=0,this.disposables=[],this.listeners={},this.curOp={},this.attached=!1,this.statusBar=null,this.options={},this.addLocalListeners(),this.ctxInsert=this.editor.createContextKey("insertMode",!0)}return f(e,[{key:"attach",value:function(){e.keyMap.vim.attach(this)}},{key:"addLocalListeners",value:function(){this.disposables.push(this.editor.onDidChangeCursorPosition(this.handleCursorChange),this.editor.onDidChangeModelContent(this.handleChange),this.editor.onKeyDown(this.handleKeyDown))}},{key:"handleReplaceMode",value:function(e,t){var n=!1,r=e,o=this.editor.getPosition(),i=new a.Range(o.lineNumber,o.column,o.lineNumber,o.column+1);if(e.startsWith("'"))r=e[1];else if("Enter"===r)r="\n";else{if("Backspace"!==r)return;var s=this.replaceStack.pop();if(!s)return;n=!0,r=s,i=new a.Range(o.lineNumber,o.column,o.lineNumber,o.column-1)}t.preventDefault(),t.stopPropagation(),this.replaceStack||(this.replaceStack=[]),n||this.replaceStack.push(this.editor.getModel().getValueInRange(i)),this.editor.executeEdits("vim",[{text:r,range:i,forceMoveMarkers:!0}]),n&&this.editor.setPosition(i.getStartPosition())}},{key:"setOption",value:function(e,t){this.state[e]=t,"theme"===e&&a.editor.setTheme(t)}},{key:"getConfiguration",value:function(){var e=this.editor,t=p;return"function"==typeof e.getConfiguration?e.getConfiguration():("EditorOption"in a.editor&&(t=a.editor.EditorOption),{readOnly:e.getOption(t.readOnly),viewInfo:{cursorWidth:e.getOption(t.cursorWidth)},fontInfo:e.getOption(t.fontInfo)})}},{key:"getOption",value:function(e){return"readOnly"===e?this.getConfiguration().readOnly:"firstLineNumber"===e?this.firstLine()+1:"indentWithTabs"===e?!this.editor.getModel().getOptions().insertSpaces:"function"==typeof this.editor.getConfiguration?this.editor.getRawConfiguration()[e]:this.editor.getRawOptions()[e]}},{key:"dispatch",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=this.listeners[e];o&&o.forEach((function(e){return e.apply(void 0,n)}))}},{key:"on",value:function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}},{key:"off",value:function(e,t){var n=this.listeners[e];n&&(this.listeners[e]=n.filter((function(e){return e!==t})))}},{key:"firstLine",value:function(){return 0}},{key:"lastLine",value:function(){return this.lineCount()-1}},{key:"lineCount",value:function(){return this.editor.getModel().getLineCount()}},{key:"defaultTextHeight",value:function(){return 1}},{key:"getLine",value:function(e){if(e<0)return"";var t=this.editor.getModel().getLineCount();return e+1>t&&(e=t-1),this.editor.getModel().getLineContent(e+1)}},{key:"getAnchorForSelection",value:function(e){return e.isEmpty()?e.getPosition():e.getDirection()===a.SelectionDirection.LTR?e.getStartPosition():e.getEndPosition()}},{key:"getHeadForSelection",value:function(e){return e.isEmpty()?e.getPosition():e.getDirection()===a.SelectionDirection.LTR?e.getEndPosition():e.getStartPosition()}},{key:"getCursor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)return y(this.editor.getPosition());var t=this.editor.getSelection();return y(t.isEmpty()?t.getPosition():"anchor"===e?this.getAnchorForSelection(t):this.getHeadForSelection(t))}},{key:"getRange",value:function(e,t){var n=k(e),r=k(t);return this.editor.getModel().getValueInRange(a.Range.fromPositions(n,r))}},{key:"getSelection",value:function(){var e=[],t=this.editor;return t.getSelections().map((function(n){e.push(t.getModel().getValueInRange(n))})),e.join("\n")}},{key:"replaceRange",value:function(e,t,n){var r=k(t),o=n?k(n):r;this.editor.executeEdits("vim",[{text:e,range:a.Range.fromPositions(r,o)}]),this.pushUndoStop()}},{key:"pushUndoStop",value:function(){this.editor.pushUndoStop()}},{key:"setCursor",value:function(e,t){var n=e;"object"!==c(e)&&((n={}).line=e,n.ch=t);var r=this.editor.getModel().validatePosition(k(n));this.editor.setPosition(k(n)),this.editor.revealPosition(r)}},{key:"somethingSelected",value:function(){return!this.editor.getSelection().isEmpty()}},{key:"operation",value:function(e,t){return e()}},{key:"listSelections",value:function(){var e=this,t=this.editor.getSelections();return!t.length||this.inVirtualSelectionMode?[{anchor:this.getCursor("anchor"),head:this.getCursor("head")}]:t.map((function(t){return t.getPosition(),t.getStartPosition(),t.getEndPosition(),{anchor:e.clipPos(y(e.getAnchorForSelection(t))),head:e.clipPos(y(e.getHeadForSelection(t)))}}))}},{key:"focus",value:function(){this.editor.focus()}},{key:"setSelections",value:function(e,t){var n=!!this.editor.getSelections().length,r=e.map((function(e,t){var r=e.anchor,o=e.head;return n?a.Selection.fromPositions(k(r),k(o)):a.Selection.fromPositions(k(o),k(r))}));if(t&&r[t]&&r.push(r.splice(t,1)[0]),r.length){var o,i=r[0];o=i.getDirection()===a.SelectionDirection.LTR?i.getEndPosition():i.getStartPosition(),this.editor.setSelections(r),this.editor.revealPosition(o)}}},{key:"setSelection",value:function(e,t){var n=a.Range.fromPositions(k(e),k(t));this.editor.setSelection(n)}},{key:"getSelections",value:function(){var e=this.editor;return e.getSelections().map((function(t){return e.getModel().getValueInRange(t)}))}},{key:"replaceSelections",value:function(e){var t=this.editor;t.getSelections().forEach((function(n,r){t.executeEdits("vim",[{range:n,text:e[r],forceMoveMarkers:!1}])}))}},{key:"toggleOverwrite",value:function(e){e?(this.enterVimMode(),this.replaceMode=!0):(this.leaveVimMode(),this.replaceMode=!1,this.replaceStack=[])}},{key:"charCoords",value:function(e,t){return{top:e.line,left:e.ch}}},{key:"coordsChar",value:function(e,t){}},{key:"clipPos",value:function(e){return y(this.editor.getModel().validatePosition(k(e)))}},{key:"setBookmark",value:function(e,t){var n=new C(this,this.$uid++,e.line,e.ch);return t&&t.insertLeft||(n.$insertRight=!0),this.marks[n.id]=n,n}},{key:"getScrollInfo",value:function(){var e,t,n=this.editor,r=(e=n.getVisibleRanges(),t=1,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return{left:0,top:r.startLineNumber-1,height:n.getModel().getLineCount(),clientHeight:r.endLineNumber-r.startLineNumber+1}}},{key:"triggerEditorAction",value:function(e){this.editor.trigger("vim",e)}},{key:"dispose",value:function(){this.dispatch("dispose"),this.removeOverlay(),e.keyMap.vim&&e.keyMap.vim.detach(this),this.disposables.forEach((function(e){return e.dispose()}))}},{key:"getInputField",value:function(){}},{key:"getWrapperElement",value:function(){}},{key:"enterVimMode",value:function(){this.ctxInsert.set(!1);var e=this.getConfiguration();this.initialCursorWidth=e.viewInfo.cursorWidth||0,this.editor.updateOptions({cursorWidth:e.fontInfo.typicalFullwidthCharacterWidth,cursorBlinking:"solid",cursorStyle:"block"})}},{key:"leaveVimMode",value:function(){this.ctxInsert.set(!0),this.editor.updateOptions({cursorWidth:this.initialCursorWidth||0,cursorBlinking:"blink",cursorStyle:"line"})}},{key:"virtualSelectionMode",value:function(){return this.inVirtualSelectionMode}},{key:"markText",value:function(){return{clear:function(){},find:function(){}}}},{key:"getUserVisibleLines",value:function(){var e=this.editor.getVisibleRanges();if(!e.length)return{top:0,bottom:0};var t={top:1/0,bottom:0};return e.reduce((function(e,t){return t.startLineNumber<e.top&&(e.top=t.startLineNumber),t.endLineNumber>e.bottom&&(e.bottom=t.endLineNumber),e}),t),t.top-=1,t.bottom-=1,t}},{key:"findPosV",value:function(e,t,n){var r=this.editor,o=t,i=n,a=k(e);if("page"===n){var s=r.getLayoutInfo().height,l=this.getConfiguration().fontInfo.lineHeight;o*=Math.floor(s/l),i="line"}return"line"===i&&(a.lineNumber+=o),y(a)}},{key:"findMatchingBracket",value:function(e){var t,n,r=k(e),o=this.editor.getModel();return(t=o.bracketPairs?o.bracketPairs.matchBracket(r):null===(n=o.matchBracket)||void 0===n?void 0:n.call(o,r))&&2===t.length?{to:y(t[1].getStartPosition())}:{to:null}}},{key:"findFirstNonWhiteSpaceCharacter",value:function(e){return this.editor.getModel().getLineFirstNonWhitespaceColumn(e+1)-1}},{key:"scrollTo",value:function(e,t){(e||t)&&(e||(t<0&&(t=this.editor.getPosition().lineNumber-t),this.editor.setScrollTop(this.editor.getTopForLineNumber(t+1))))}},{key:"moveCurrentLineTo",value:function(e){var t,n=this.editor,r=n.getPosition(),o=a.Range.fromPositions(r,r);switch(e){case"top":return void n.revealRangeAtTop(o);case"center":return void n.revealRangeInCenter(o);case"bottom":return void(null===(t=n._revealRange)||void 0===t||t.call(n,o,4))}}},{key:"getSearchCursor",value:function(e,t){var n=!1,r=!1;e instanceof RegExp&&!e.global&&(n=!e.ignoreCase,e=e.source,r=!0),null==t.ch&&(t.ch=Number.MAX_VALUE);var o=k(t),i=this,a=this.editor,s=null,l=a.getModel(),c=l.findMatches(e,!1,r,n)||[];return{getMatches:function(){return c},findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},jumpTo:function(e){if(!c||!c.length)return!1;var t=c[e];return s=t.range,i.highlightRanges([s],"currentFindMatch"),i.highlightRanges(c.map((function(e){return e.range})).filter((function(e){return!e.equalsRange(s)}))),s},find:function(t){if(!c||!c.length)return!1;var a;if(t){var u=s?s.getStartPosition():o;if(!(a=l.findPreviousMatch(e,u,r,n))||!a.range.getStartPosition().isBeforeOrEqual(u))return!1}else{var h=s?l.getPositionAt(l.getOffsetAt(s.getEndPosition())+1):o;if(!(a=l.findNextMatch(e,h,r,n))||!h.isBeforeOrEqual(a.range.getStartPosition()))return!1}return s=a.range,i.highlightRanges([s],"currentFindMatch"),i.highlightRanges(c.map((function(e){return e.range})).filter((function(e){return!e.equalsRange(s)}))),s},from:function(){return s&&y(s.getStartPosition())},to:function(){return s&&y(s.getEndPosition())},replace:function(e){s&&(a.executeEdits("vim",[{range:s,text:e,forceMoveMarkers:!0}],(function(e){var t=e[0].range,n=t.endLineNumber,r=t.endColumn;s=s.setEndPosition(n,r)})),a.setPosition(s.getStartPosition()))}}}},{key:"highlightRanges",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"findMatch",n="decoration".concat(t);return this[n]=this.editor.deltaDecorations(this[n]||[],e.map((function(e){return{range:e,options:{stickiness:a.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,zIndex:13,className:t,showIfCollapsed:!0}}}))),this[n]}},{key:"addOverlay",value:function(e,t,n){var r=e.query,o=!1,i=!1;r&&r instanceof RegExp&&!r.global&&(i=!0,o=!r.ignoreCase,r=r.source);var a=this.editor.getModel().findNextMatch(r,this.editor.getPosition(),i,o);a&&a.range&&this.highlightRanges([a.range])}},{key:"removeOverlay",value:function(){var e=this;["currentFindMatch","findMatch"].forEach((function(t){e.editor.deltaDecorations(e["decoration".concat(t)]||[],[])}))}},{key:"scrollIntoView",value:function(e){e&&this.editor.revealPosition(k(e))}},{key:"moveH",value:function(e,t){if("char"===t){var n=this.editor.getPosition();this.editor.setPosition(new a.Position(n.lineNumber,n.column+e))}}},{key:"scanForBracket",value:function(t,n,r,o){for(var i=o.bracketRegex,a=k(t),s=this.editor.getModel(),l=(-1===n?s.findPreviousMatch:s.findNextMatch).bind(s),c=[],u=0;;){if(u>10)return;var h=l(i.source,a,!0,!0,null,!0),f=h.matches[0];if(void 0===h)return;var d=e.matchingBrackets[f];if(d&&">"===d.charAt(1)==n>0)c.push(f);else{if(0===c.length)return{pos:y(h.range.getStartPosition())};c.pop()}a=s.getPositionAt(s.getOffsetAt(h.range.getStartPosition())+n),u+=1}}},{key:"indexFromPos",value:function(e){return this.editor.getModel().getOffsetAt(k(e))}},{key:"posFromIndex",value:function(e){return y(this.editor.getModel().getPositionAt(e))}},{key:"indentLine",value:function(e){var t,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.editor;t=r._getViewModel?r._getViewModel().cursorConfig:r._getCursors().context.config;var o=new a.Position(e+1,1),i=a.Selection.fromPositions(o,o);r.executeCommand("vim",new s.ShiftCommand(i,{isUnshift:!n,tabSize:t.tabSize,indentSize:t.indentSize,insertSpaces:t.insertSpaces,useTabStops:t.useTabStops,autoIndent:t.autoIndent}))}},{key:"setStatusBar",value:function(e){this.statusBar=e}},{key:"openDialog",value:function(e,t,n){if(this.statusBar)return this.statusBar.setSec(e,t,n)}},{key:"openNotification",value:function(e){this.statusBar&&this.statusBar.showNotification(e)}},{key:"smartIndent",value:function(){this.editor.getAction("editor.action.formatSelection").run()}},{key:"moveCursorTo",value:function(e){var t=this.editor.getPosition();"start"===e?t.column=1:"end"===e&&(t.column=this.editor.getModel().getLineMaxColumn(t.lineNumber)),this.editor.setPosition(t)}},{key:"execCommand",value:function(e){switch(e){case"goLineLeft":this.moveCursorTo("start");break;case"goLineRight":this.moveCursorTo("end");break;case"indentAuto":this.smartIndent()}}}])}();S.Pos=g,S.signal=function(e,t,n){e.dispatch(t,n)},S.on=function(){},S.off=function(){},S.addClass=function(){},S.rmClass=function(){},S.defineOption=function(){},S.keyMap={default:function(e){return function(e){return!0}}},S.matchingBrackets={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"},S.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||m.test(e))},S.keyName=w,S.StringStream=v,S.e_stop=function(e){return e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,S.e_preventDefault(e),!1},S.e_preventDefault=function(e){return e.preventDefault?(e.preventDefault(),e.browserEvent&&e.browserEvent.preventDefault()):e.returnValue=!1,!1},S.commands={redo:function(e){e.editor.getModel().redo()},undo:function(e){e.editor.getModel().undo()},newlineAndIndent:function(e){e.triggerEditorAction("editor.action.insertLineAfter")}},S.lookupKey=function e(t,n,r){"string"==typeof n&&(n=S.keyMap[n]);var o="function"==typeof n?n(t):n[t];if(!1===o)return"nothing";if("..."===o)return"multi";if(null!=o&&r(o))return"handled";if(n.fallthrough){if(!Array.isArray(n.fallthrough))return e(t,n.fallthrough,r);for(var i=0;i<n.fallthrough.length;i++){var a=e(t,n.fallthrough[i],r);if(a)return a}}},S.defineExtension=function(e,t){S.prototype[e]=t};var M=function(){var e=this;this.handleKeyDown=function(t){if(!(t.browserEvent.defaultPrevented&t.keyCode!==a.KeyCode.Escape)&&e.attached){var n=w(t);if(e.replaceMode&&e.handleReplaceMode(n,t),n){var r=e.state.keyMap;if(S.keyMap[r]&&S.keyMap[r].call){var o=S.keyMap[r].call(n,e);if(o){t.preventDefault(),t.stopPropagation();try{o()}catch(e){console.error(e)}}}}}},this.handleCursorChange=function(t){var n=t.position,r=(t.source,e.editor),o=r.getSelection();if(!e.ctxInsert.get()&&"mouse"===t.source&&o.isEmpty()){var i=r.getModel().getLineMaxColumn(n.lineNumber);if(t.position.column===i)return void r.setPosition(new a.Position(t.position.lineNumber,i-1))}e.dispatch("cursorActivity",e,t)},this.handleChange=function(t){var n={text:t.changes.reduce((function(e,t){return e.push(t.text),e}),[]),origin:"+input"},r=e.curOp=e.curOp||{};r.changeHandlers||(r.changeHandlers=e.listeners.change&&e.listeners.change.slice()),e.virtualSelectionMode()||(r.lastChange?r.lastChange.next=r.lastChange=n:r.lastChange=r.change=n,e.dispatch("change",e,n))}};const x=S;function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}var A=x.Pos;function L(e,t){var n=e.state.vim;if(!n||n.insertMode)return t.head;var r=n.sel.head;return r?n.visualBlock&&t.head.line!=r.line?void 0:t.from()!=t.anchor||t.empty()||t.head.line!=r.line||t.head.ch==r.ch?t.head:new A(t.head.line,t.head.ch-1):t.head}var T=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<Del>",type:"keyToKey",toKeys:"x",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",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:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",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:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",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:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{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<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",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:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",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:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",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:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",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<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",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:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',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<CR>",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:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",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"}],E=T.length,I=[{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:"vglobal",shortName:"v"},{name:"global",shortName:"g"}];x.Vim=function(){function e(e,n){e.attached=!1,this==x.keyMap.vim&&(e.options.$customCursor=null),n&&n.attach==t||function(e){e.setOption("disableInput",!1),e.off("cursorActivity",Ye),e.state.vim=null,je&&clearTimeout(je),e.leaveVimMode()}(e)}function t(e,n){this==x.keyMap.vim&&(e.attached=!0,e.curOp&&(e.curOp.selectionChanged=!0),e.options.$customCursor=L),n&&n.attach==t||function(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),x.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",Ye),D(e),e.enterVimMode()}(e)}function n(e,t){if(t){if(this[e])return this[e];var n=function(e){if("'"==e.charAt(0))return e.charAt(1);if("AltGraph"===e)return!1;var t=e.split(/-(?!$)/),n=t[t.length-1];if(1==t.length&&1==t[0].length)return!1;if(2==t.length&&"Shift"==t[0]&&1==n.length)return!1;for(var i=!1,a=0;a<t.length;a++){var s=t[a];s in r?t[a]=r[s]:i=!0,s in o&&(t[a]=o[s])}return!!i&&(v(n)&&(t[t.length-1]=n.toLowerCase()),"<"+t.join("-")+">")}(e);if(!n)return!1;var i=V.findKey(t,n);return"function"==typeof i&&x.signal(t,"vim-keypress",n),i}}x.defineOption("vimMode",!1,(function(e,t,n){t&&"vim"!=e.getOption("keyMap")?e.setOption("keyMap","vim"):!t&&n!=x.Init&&/^vim/.test(e.getOption("keyMap"))&&e.setOption("keyMap","default")}));var r={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A",CapsLock:""},o={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"},i=/[\d]/,a=[x.isWordChar,function(e){return e&&!x.isWordChar(e)&&!/\s/.test(e)}],s=[function(e){return/\S/.test(e)}];function l(e,t){for(var n=[],r=e;r<e+t;r++)n.push(String.fromCharCode(r));return n}var c,u=l(65,26),h=l(97,26),f=l(48,10),d=[].concat(u,h,f,["<",">"]),p=[].concat(u,h,f,["-",'"',".",":","_","/"]);try{c=new RegExp("^[\\p{Lu}]$","u")}catch(e){c=/^[A-Z]$/}function m(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function g(e){return/^[a-z]$/.test(e)}function v(e){return c.test(e)}function y(e){return/^\s*$/.test(e)}function k(e){return-1!=".?!".indexOf(e)}function C(e,t){for(var n=0;n<t.length;n++)if(t[n]==e)return!0;return!1}var w={};function S(e,t,n,r,o){if(void 0===t&&!o)throw Error("defaultValue is required unless callback is provided");if(n||(n="string"),w[e]={type:n,defaultValue:t,callback:o},r)for(var i=0;i<r.length;i++)w[r[i]]=w[e];t&&M(e,t)}function M(e,t,n,r){var o=w[e],i=(r=r||{}).scope;if(!o)return new Error("Unknown option: "+e);if("boolean"==o.type){if(t&&!0!==t)return new Error("Invalid argument: "+e+"="+t);!1!==t&&(t=!0)}o.callback?("local"!==i&&o.callback(t,void 0),"global"!==i&&n&&o.callback(t,n)):("local"!==i&&(o.value="boolean"==o.type?!!t:t),"global"!==i&&n&&(n.state.vim.options[e]={value:t}))}function R(e,t,n){var r=w[e],o=(n=n||{}).scope;if(!r)return new Error("Unknown option: "+e);if(r.callback){var i=t&&r.callback(void 0,t);return"global"!==o&&void 0!==i?i:"local"!==o?r.callback():void 0}return((i="global"!==o&&t&&t.state.vim.options[e])||"local"!==o&&r||{}).value}S("filetype",void 0,"string",["ft"],(function(e,t){if(void 0!==t){if(void 0===e)return"null"==(n=t.getOption("mode"))?"":n;var n=""==e?"null":e;t.setOption("mode",n)}}));var O,B,P=function(){var e=100,t=-1,n=0,r=0,o=new Array(e);function i(i,a){(t+=a)>n?t=n:t<r&&(t=r);var s=o[(e+t)%e];if(s&&!s.find()){var l,c=a>0?1:-1,u=i.getCursor();do{if((s=o[(e+(t+=c))%e])&&(l=s.find())&&!ne(u,l))break}while(t<n&&t>r)}return s}return{cachedCursor:void 0,add:function(i,a,s){var l=o[t%e];function c(n){var r=++t%e,a=o[r];a&&a.clear(),o[r]=i.setBookmark(n)}if(l){var u=l.find();u&&!ne(u,a)&&c(a)}else c(a);c(s),n=t,(r=t-e+1)<0&&(r=0)},find:function(e,n){var r=t,o=i(e,n);return t=r,o&&o.find()},move:i}},N=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};function K(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=N()}function D(e){return e.state.vim||(e.state.vim={inputState:new _,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}}),e.state.vim}function j(){for(var e in O={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:P(),macroModeState:new K,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new F({}),searchHistoryController:new U,exCommandHistoryController:new U},w){var t=w[e];t.value=t.defaultValue}}K.prototype={exitMacroRecordMode:function(){var e=O.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1},enterMacroRecordMode:function(e,t){var n=O.registerController.getRegister(t);n&&(n.clear(),this.latestRegister=t,e.openDialog&&(this.onRecordingDone=e.openDialog(document.createTextNode("(recording)["+t+"]"),null,{bottom:!0})),this.isRecording=!0)}};var V={buildKeyMap:function(){},getRegisterController:function(){return O.registerController},resetVimGlobalState_:j,getVimGlobalState_:function(){return O},maybeInitVimState_:D,suppressErrorLogging:!1,InsertModeKey:Ze,map:function(e,t,n){Je.map(e,t,n)},unmap:function(e,t){return Je.unmap(e,t)},noremap:function(e,t,n){function r(e){return e?[e]:["normal","insert","visual"]}for(var o=r(n),i=T.length,a=i-E;a<i&&o.length;a++){var s=T[a];if(!(s.keys!=t||n&&s.context&&s.context!==n||"ex"===s.type.substr(0,2)||"key"===s.type.substr(0,3))){var l={};for(var c in s)l[c]=s[c];l.keys=e,n&&!l.context&&(l.context=n),this._mapCommand(l);var u=r(s.context);o=o.filter((function(e){return-1===u.indexOf(e)}))}}},mapclear:function(e){var t=T.length,n=E,r=T.slice(0,t-n);if(T=T.slice(t-n),e)for(var o=r.length-1;o>=0;o--){var i=r[o];if(e!==i.context)if(i.context)this._mapCommand(i);else{var a=["normal","insert","visual"];for(var s in a)if(a[s]!==e){var l={};for(var c in i)l[c]=i[c];l.context=a[s],this._mapCommand(l)}}}},setOption:M,getOption:R,defineOption:S,defineEx:function(e,t,n){if(t){if(0!==e.indexOf(t))throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered')}else t=e;qe[e]=n,Je.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,n){var r=this.findKey(e,t,n);if("function"==typeof r)return r()},findKey:function(e,t,n){var r,o=D(e);function i(){if("<Esc>"==t){if(o.visualMode)me(e);else{if(!o.insertMode)return;ze(e)}return W(e),!0}}return!1===(r=o.insertMode?function(){if(i())return!0;for(var n=o.inputState.keyBuffer=o.inputState.keyBuffer+t,r=1==t.length,a=$.matchCommand(n,T,o.inputState,"insert");n.length>1&&"full"!=a.type;){n=o.inputState.keyBuffer=n.slice(1);var s=$.matchCommand(n,T,o.inputState,"insert");"none"!=s.type&&(a=s)}if("none"==a.type)return W(e),!1;if("partial"==a.type)return B&&window.clearTimeout(B),B=window.setTimeout((function(){o.insertMode&&o.inputState.keyBuffer&&W(e)}),R("insertModeEscKeysTimeout")),!r;if(B&&window.clearTimeout(B),r){for(var l=e.listSelections(),c=0;c<l.length;c++){var u=l[c].head;e.replaceRange("",Y(u,0,-(n.length-1)),u,"+input")}O.macroModeState.lastInsertModeChanges.changes.pop()}return W(e),a.command}():function(){if(function(){var r=O.macroModeState;if(r.isRecording){if("q"==t)return r.exitMacroRecordMode(),W(e),!0;"mapping"!=n&&function(e,t){if(!e.isPlaying){var n=e.latestRegister,r=O.registerController.getRegister(n);r&&r.pushText(t)}}(r,t)}}()||i())return!0;var r=o.inputState.keyBuffer=o.inputState.keyBuffer+t;if(/^[1-9]\d*$/.test(r))return!0;if(!(l=/^(\d*)(.*)$/.exec(r)))return W(e),!1;var a=o.visualMode?"visual":"normal",s=l[2]||l[1];o.inputState.operatorShortcut&&o.inputState.operatorShortcut.slice(-1)==s&&(s=o.inputState.operatorShortcut);var l,c=$.matchCommand(s,T,o.inputState,a);return"none"==c.type?(W(e),!1):"partial"==c.type||(o.inputState.keyBuffer="",(l=/^(\d*)(.*)$/.exec(r))[1]&&"0"!=l[1]&&o.inputState.pushRepeatDigit(l[1]),c.command)}())?o.insertMode||1!==t.length?void 0:function(){return!0}:!0===r?function(){return!0}:function(){return e.operation((function(){e.curOp.isVimOp=!0;try{"keyToKey"==r.type?function(n){for(var r;n;)r=/<\w+-.+?>|<\w+>|./.exec(n),t=r[0],n=n.substring(r.index+t.length),V.handleKey(e,t,"mapping")}(r.toKeys):$.processCommand(e,o,r)}catch(t){throw e.state.vim=void 0,D(e),V.suppressErrorLogging||console.log(t),t}return!0}))}},handleEx:function(e,t){Je.processCommand(e,t)},defineMotion:function(e,t){q[e]=t},defineAction:function(e,t){Q[e]=t},defineOperator:function(e,t){z[e]=t},mapCommand:function(e,t,n,r,o){var i={keys:e,type:t};for(var a in i[t]=n,i[t+"Args"]=r,o)i[a]=o[a];Qe(i)},_mapCommand:Qe,defineRegister:function(e,t){var n=O.registerController.registers;if(!e||1!=e.length)throw Error("Register name must be 1 character");if(n[e])throw Error("Register already defined "+e);n[e]=t,p.push(e)},exitVisualMode:me,exitInsertMode:ze};function _(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function W(e,t){e.state.vim.inputState=new _,x.signal(e,"vim-command-done",t)}function H(e,t,n){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!n}function F(e){this.registers=e,this.unnamedRegister=e['"']=new H,e["."]=new H,e[":"]=new H,e["/"]=new H}function U(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}_.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},_.prototype.getRepeat=function(){var e=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(e=1,this.prefixRepeat.length>0&&(e*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(e*=parseInt(this.motionRepeat.join(""),10))),e},H.prototype={setText:function(e,t,n){this.keyBuffer=[e||""],this.linewise=!!t,this.blockwise=!!n},pushText:function(e,t){t&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(e)},pushInsertModeChanges:function(e){this.insertModeChanges.push(N(e))},pushSearchQuery:function(e){this.searchQueries.push(e)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},F.prototype={pushText:function(e,t,n,r,o){if("_"!==e){r&&"\n"!==n.charAt(n.length-1)&&(n+="\n");var i=this.isValidRegister(e)?this.getRegister(e):null;if(i)v(e)?i.pushText(n,r):i.setText(n,r,o),this.unnamedRegister.setText(i.toString(),r);else{switch(t){case"yank":this.registers[0]=new H(n,r,o);break;case"delete":case"change":-1==n.indexOf("\n")?this.registers["-"]=new H(n,r):(this.shiftNumericRegisters_(),this.registers[1]=new H(n,r))}this.unnamedRegister.setText(n,r,o)}}},getRegister:function(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new H),this.registers[e]):this.unnamedRegister},isValidRegister:function(e){return e&&C(e,p)},shiftNumericRegisters_:function(){for(var e=9;e>=2;e--)this.registers[e]=this.getRegister(""+(e-1))}},U.prototype={nextMatch:function(e,t){var n=this.historyBuffer,r=t?-1:1;null===this.initialPrefix&&(this.initialPrefix=e);for(var o=this.iterator+r;t?o>=0:o<n.length;o+=r)for(var i=n[o],a=0;a<=i.length;a++)if(this.initialPrefix==i.substring(0,a))return this.iterator=o,i;return o>=n.length?(this.iterator=n.length,this.initialPrefix):o<0?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);t>-1&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var $={matchCommand:function(e,t,n,r){var o,i=function(e,t,n,r){for(var o,i=[],a=[],s=0;s<t.length;s++){var l=t[s];"insert"==n&&"insert"!=l.context||l.context&&l.context!=n||r.operator&&"action"==l.type||!(o=Z(e,l.keys))||("partial"==o&&i.push(l),"full"==o&&a.push(l))}return{partial:i.length&&i,full:a.length&&a}}(e,t,r,n);if(!i.full&&!i.partial)return{type:"none"};if(!i.full&&i.partial)return{type:"partial"};for(var a=0;a<i.full.length;a++){var s=i.full[a];o||(o=s)}if("<character>"==o.keys.slice(-11)){var l=function(e){var t=/^.*(<[^>]+>)$/.exec(e),n=t?t[1]:e.slice(-1);if(n.length>1)switch(n){case"<CR>":n="\n";break;case"<Space>":n=" ";break;default:n=""}return n}(e);if(!l)return{type:"none"};n.selectedCharacter=l}return{type:"full",command:o}},processCommand:function(e,t,n){switch(t.inputState.repeatOverride=n.repeatOverride,n.type){case"motion":this.processMotion(e,t,n);break;case"operator":this.processOperator(e,t,n);break;case"operatorMotion":this.processOperatorMotion(e,t,n);break;case"action":this.processAction(e,t,n);break;case"search":this.processSearch(e,t,n);break;case"ex":case"keyToEx":this.processEx(e,t,n)}},processMotion:function(e,t,n){t.inputState.motion=n.motion,t.inputState.motionArgs=X(n.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,n){var r=t.inputState;if(r.operator){if(r.operator==n.operator)return r.motion="expandToLine",r.motionArgs={linewise:!0},void this.evalInput(e,t);W(e)}r.operator=n.operator,r.operatorArgs=X(n.operatorArgs),n.keys.length>1&&(r.operatorShortcut=n.keys),n.exitVisualBlock&&(t.visualBlock=!1,de(e)),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,n){var r=t.visualMode,o=X(n.operatorMotionArgs);o&&r&&o.visualLine&&(t.visualLine=!0),this.processOperator(e,t,n),r||this.processMotion(e,t,n)},processAction:function(e,t,n){var r=t.inputState,o=r.getRepeat(),i=!!o,a=X(n.actionArgs)||{};r.selectedCharacter&&(a.selectedCharacter=r.selectedCharacter),n.operator&&this.processOperator(e,t,n),n.motion&&this.processMotion(e,t,n),(n.motion||n.operator)&&this.evalInput(e,t),a.repeat=o||1,a.repeatIsExplicit=i,a.registerName=r.registerName,W(e),t.lastMotion=null,n.isEdit&&this.recordLastEdit(t,r,n),Q[n.action](e,a,t)},processSearch:function(e,t,n){if(e.getSearchCursor){var r=n.searchArgs.forward,o=n.searchArgs.wholeWordOnly;Ee(e).setReversed(!r);var i=r?"/":"?",a=Ee(e).getQuery(),s=e.getScrollInfo();switch(n.searchArgs.querySrc){case"prompt":var l=O.macroModeState;l.isPlaying?f(h=l.replaySearchQueries.shift(),!0,!1):Ke(e,{onClose:function(t){e.scrollTo(s.left,s.top),f(t,!0,!0);var n=O.macroModeState;n.isRecording&&function(e,t){if(!e.isPlaying){var n=e.latestRegister,r=O.registerController.getRegister(n);r&&r.pushSearchQuery&&r.p