Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed new file

  • Loading branch information...
commit 3f0eb5c0796f753524db9d8110e4d147b07440f8 1 parent 68f4fa0
@deemeetar deemeetar authored
Showing with 0 additions and 45 deletions.
  1. +0 −45 lib/util/closeElement.js
View
45 lib/util/closeElement.js
@@ -1,45 +0,0 @@
-/**
- * Element-closer extension for CodeMirror.
- *
- * This extension adds a "closeElement" utility function that can be used with key bindings to
- * insert a matching end element such as ", ' , {, [ (. It can
- *
- *
- *
- * @author Dimitar Spiroski
- * Contributed under the same license terms as CodeMirror.
- */
-(function() {
- /** Option that allows element closing behavior to be toggled. Default is true. */
- CodeMirror.defaults['closeElementEnabled'] = true;
-
-
- CodeMirror.defineExtension("closeElement", function(cm, ch) {
- if (!cm.getOption('closeElementEnabled')) {
- throw CodeMirror.Pass;
- }
-
- var pos = cm.getCursor(),
- closingElement = getClosingElementFor(ch);
-
- cm.replaceRange(ch + closingElement, pos);
- cm.setCursor({line: pos.line, ch: pos.ch + 1}); // set cursor inbetween
-
- });
-
- function getClosingElementFor(ch) {
- switch (ch){
- case "\"":
- return ch;
- case "'":
- return ch;
- case "{":
- return "}";
- case "[":
- return "]";
- case "(":
- return ")";
- }
- }
-
-})();
Please sign in to comment.
Something went wrong with that request. Please try again.