Showing with 2,060 additions and 1,937 deletions.
  1. +1 −0 AUTHORS
  2. +1 −1 addon/edit/closetag.js
  3. +1 −1 addon/edit/continuelist.js
  4. +6 −4 addon/fold/foldcode.js
  5. +21 −0 addon/fold/foldgutter.css
  6. +2 −0 addon/fold/foldgutter.js
  7. +21 −7 addon/fold/indent-fold.js
  8. +3 −19 addon/hint/javascript-hint.js
  9. +105 −0 addon/hint/sql-hint.js
  10. +1 −0 addon/hint/xml-hint.js
  11. +1 −0 addon/lint/lint.css
  12. +2 −0 addon/search/search.js
  13. +1 −1 addon/tern/tern.js
  14. +99 −0 addon/wrap/hardwrap.js
  15. +0 −1 bower.json
  16. +4 −24 demo/folding.html
  17. +69 −0 demo/hardwrap.html
  18. +2 −0 demo/theme.html
  19. +5 −0 doc/compress.html
  20. +4 −0 doc/docs.css
  21. +184 −72 doc/manual.html
  22. +7 −0 doc/realworld.html
  23. +16 −0 doc/releases.html
  24. +1 −1 index.html
  25. +55 −17 keymap/vim.js
  26. +1 −1 lib/codemirror.css
  27. +42 −19 lib/codemirror.js
  28. +314 −313 mode/coffeescript/coffeescript.js
  29. +19 −7 mode/css/css.js
  30. +5 −1 mode/css/scss_test.js
  31. +5 −1 mode/css/test.js
  32. +147 −0 mode/eiffel/eiffel.js
  33. +430 −0 mode/eiffel/index.html
  34. +2 −1 mode/gfm/gfm.js
  35. +168 −0 mode/gherkin/gherkin.js
  36. +48 −0 mode/gherkin/index.html
  37. +2 −0 mode/index.html
  38. +110 −22 mode/less/less.js
  39. +3 −1 mode/meta.js
  40. +4 −4 mode/php/php.js
  41. +1 −1 mode/smartymixed/index.html
  42. +6 −1 mode/smartymixed/smartymixed.js
  43. +2 −1 mode/sql/index.html
  44. +15 −2 mode/sql/sql.js
  45. +7 −3 mode/xml/xml.js
  46. +1 −1 package.json
  47. +0 −1,372 test/lint/parse-js.js
  48. +16 −8 test/mode_test.js
  49. +35 −0 test/vim_test.js
  50. +1 −1 theme/3024-day.css
  51. +1 −1 theme/3024-night.css
  52. +1 −1 theme/ambiance.css
  53. +1 −1 theme/base16-dark.css
  54. +1 −1 theme/base16-light.css
  55. +1 −1 theme/blackboard.css
  56. +1 −1 theme/cobalt.css
  57. +1 −1 theme/eclipse.css
  58. +1 −1 theme/elegant.css
  59. +1 −1 theme/erlang-dark.css
  60. +1 −1 theme/lesser-dark.css
  61. +35 −0 theme/mbo.css
  62. +1 −1 theme/midnight.css
  63. +1 −1 theme/monokai.css
  64. +1 −1 theme/night.css
  65. +1 −1 theme/paraiso-dark.css
  66. +1 −1 theme/paraiso-light.css
  67. +1 −1 theme/rubyblue.css
  68. +7 −7 theme/solarized.css
  69. +1 −1 theme/the-matrix.css
  70. +1 −1 theme/tomorrow-night-eighties.css
  71. +1 −1 theme/twilight.css
  72. +1 −1 theme/vibrant-ink.css
  73. +1 −1 theme/xq-dark.css
  74. +1 −1 theme/xq-light.css
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Ford_Lawnmower
Gabriel Nahmias
galambalazs
Gautam Mehta
Glenn Jorde
Glenn Ruehle
Golevka
Gordon Smith
Expand Down
2 changes: 1 addition & 1 deletion addon/edit/closetag.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
function autoCloseSlash(cm) {
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
if (tok.string.charAt(0) != "<" || inner.mode.name != "xml") return CodeMirror.Pass;
if (tok.string.charAt(0) != "<" || tok.start != pos.ch - 1 || inner.mode.name != "xml") return CodeMirror.Pass;

var tagName = state.context && state.context.tagName;
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
Expand Down
2 changes: 1 addition & 1 deletion addon/edit/continuelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
var pos = cm.getCursor(),
inList = cm.getStateAfter(pos.line).list,
inList = cm.getStateAfter(pos.line).list !== false,
match;

if (!inList || !(match = cm.getLine(pos.line).match(listRE))) {
Expand Down
10 changes: 6 additions & 4 deletions addon/fold/foldcode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
"use strict";

function doFold(cm, pos, options) {
function doFold(cm, pos, options, force) {
var finder = options && (options.call ? options : options.rangeFinder);
if (!finder) finder = cm.getHelper(pos, "fold");
if (!finder) return;
Expand All @@ -13,7 +13,7 @@
if (!range || range.to.line - range.from.line < minSize) return null;
var marks = cm.findMarksAt(range.from);
for (var i = 0; i < marks.length; ++i) {
if (marks[i].__isFold) {
if (marks[i].__isFold && force !== "fold") {
if (!allowFolded) return null;
range.cleared = true;
marks[i].clear();
Expand All @@ -27,7 +27,7 @@
pos = CodeMirror.Pos(pos.line - 1, 0);
range = getRange(false);
}
if (!range || range.cleared) return;
if (!range || range.cleared || force === "unfold") return;

var myWidget = makeWidget(options);
CodeMirror.on(myWidget, "mousedown", function() { myRange.clear(); });
Expand Down Expand Up @@ -59,7 +59,9 @@
};

// New-style interface
CodeMirror.defineExtension("foldCode", function(pos, options) { doFold(this, pos, options); });
CodeMirror.defineExtension("foldCode", function(pos, options, force) {
doFold(this, pos, options, force);
});

CodeMirror.registerHelper("fold", "combine", function() {
var funcs = Array.prototype.slice.call(arguments, 0);
Expand Down
21 changes: 21 additions & 0 deletions addon/fold/foldgutter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.CodeMirror-foldmarker {
color: blue;
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
font-family: arial;
line-height: .3;
cursor: pointer;
}
.CodeMirror-foldgutter {
width: .7em;
}
.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
color: #555;
cursor: pointer;
}
.CodeMirror-foldgutter-open:after {
content: "\25BE";
}
.CodeMirror-foldgutter-folded:after {
content: "\25B8";
}
2 changes: 2 additions & 0 deletions addon/fold/foldgutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
cm.off("viewportChange", onViewportChange);
cm.off("fold", onFold);
cm.off("unfold", onFold);
cm.off("swapDoc", updateInViewport);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
Expand All @@ -19,6 +20,7 @@
cm.on("viewportChange", onViewportChange);
cm.on("fold", onFold);
cm.on("unfold", onFold);
cm.on("swapDoc", updateInViewport);
}
});

Expand Down
28 changes: 21 additions & 7 deletions addon/fold/indent-fold.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
var curLine = cm.getLine(i);
if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent &&
CodeMirror.countColumn(cm.getLine(i-1), null, tabSize) > myIndent)
var lastLine = cm.lastLine(),
tabSize = cm.getOption("tabSize"),
firstLine = cm.getLine(start.line),
myIndent = CodeMirror.countColumn(firstLine, null, tabSize);

function foldEnded(curColumn, prevColumn) {
return curColumn < myIndent ||
(curColumn == myIndent && prevColumn >= myIndent) ||
(curColumn > myIndent && i == lastLine);
}

for (var i = start.line + 1; i <= lastLine; i++) {
var curColumn = CodeMirror.countColumn(cm.getLine(i), null, tabSize);
var prevColumn = CodeMirror.countColumn(cm.getLine(i-1), null, tabSize);

if (foldEnded(curColumn, prevColumn)) {
var lastFoldLineNumber = curColumn > myIndent && i == lastLine ? i : i-1;
var lastFoldLine = cm.getLine(lastFoldLineNumber);
return {from: CodeMirror.Pos(start.line, firstLine.length),
to: CodeMirror.Pos(i, curLine.length)};
to: CodeMirror.Pos(lastFoldLineNumber, lastFoldLine.length)};
}
}
});

CodeMirror.indentRangeFinder = CodeMirror.fold.indent; // deprecated
22 changes: 3 additions & 19 deletions addon/hint/javascript-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.string != ".") return;
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.string == ')') {
var level = 1;
do {
tprop = getToken(editor, Pos(cur.line, tprop.start));
switch (tprop.string) {
case ')': level++; break;
case '(': level--; break;
default: break;
}
} while (level > 0);
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.type.indexOf("variable") === 0)
tprop.type = "function";
else return; // no clue
}
if (!context) var context = [];
context.push(tprop);
}
Expand Down Expand Up @@ -110,11 +95,11 @@
for (var name in obj) maybeAdd(name);
}

if (context) {
if (context && context.length) {
// If this is a property, see if it belongs to some object we can
// find in the current environment.
var obj = context.pop(), base;
if (obj.type.indexOf("variable") === 0) {
if (obj.type && obj.type.indexOf("variable") === 0) {
if (options && options.additionalContext)
base = options.additionalContext[obj.string];
base = base || window[obj.string];
Expand All @@ -132,8 +117,7 @@
while (base != null && context.length)
base = base[context.pop().string];
if (base != null) gatherCompletions(base);
}
else {
} else {
// If not, just look in the window object and any local scope
// (reading into JS mode internals to get at the local and global variables)
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
Expand Down
105 changes: 105 additions & 0 deletions addon/hint/sql-hint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
(function () {
"use strict";

var tables;
var keywords;

function getKeywords(editor) {
var mode = editor.doc.modeOption;
if(mode === "sql") mode = "text/x-sql";
return CodeMirror.resolveMode(mode).keywords;
}

function match(string, word) {
var len = string.length;
var sub = word.substr(0, len);
return string.toUpperCase() === sub.toUpperCase();
}

function addMatches(result, search, wordlist, formatter) {
for(var word in wordlist) {
if(!wordlist.hasOwnProperty(word)) continue;
if(Array.isArray(wordlist)) {
word = wordlist[word];
}
if(match(search, word)) {
result.push(formatter(word));
}
}
}

function columnCompletion(result, editor) {
var cur = editor.getCursor();
var token = editor.getTokenAt(cur);
var string = token.string.substr(1);
var prevCur = CodeMirror.Pos(cur.line, token.start);
var table = editor.getTokenAt(prevCur).string;
var columns = tables[table];
if(!columns) {
table = findTableByAlias(table, editor);
}
columns = tables[table];
if(!columns) {
return;
}
addMatches(result, string, columns,
function(w) {return "." + w;});
}

function eachWord(line, f) {
var words = line.text.split(" ");
for(var i = 0; i < words.length; i++) {
f(words[i]);
}
}

// Tries to find possible table name from alias.
function findTableByAlias(alias, editor) {
var aliasUpperCase = alias.toUpperCase();
var previousWord = "";
var table = "";

editor.eachLine(function(line) {
eachWord(line, function(word) {
var wordUpperCase = word.toUpperCase();
if(wordUpperCase === aliasUpperCase) {
if(tables.hasOwnProperty(previousWord)) {
table = previousWord;
}
}
if(wordUpperCase !== "AS") {
previousWord = word;
}
});
});
return table;
}

function sqlHint(editor, options) {
tables = (options && options.tables) || {};
keywords = keywords || getKeywords(editor);
var cur = editor.getCursor();
var token = editor.getTokenAt(cur);

var result = [];

var search = token.string.trim();

addMatches(result, search, keywords,
function(w) {return w.toUpperCase();});

addMatches(result, search, tables,
function(w) {return w;});

if(search.lastIndexOf('.') === 0) {
columnCompletion(result, editor);
}

return {
list: result,
from: CodeMirror.Pos(cur.line, token.start),
to: CodeMirror.Pos(cur.line, token.end)
};
}
CodeMirror.registerHelper("hint", "sql", sqlHint);
})();
1 change: 1 addition & 0 deletions addon/hint/xml-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
Pos(cur.line, token.type == "string" ? token.start : token.end));
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget
if (token.type == "string") {
prefix = token.string;
if (/['"]/.test(token.string.charAt(0))) {
Expand Down
1 change: 1 addition & 0 deletions addon/lint/lint.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
padding: 2px 5px;
position: fixed;
white-space: pre;
white-space: pre-wrap;
z-index: 100;
max-width: 600px;
opacity: 0;
Expand Down
2 changes: 2 additions & 0 deletions addon/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
if (!cursor.find(rev)) return;
}
cm.setSelection(cursor.from(), cursor.to());
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
state.posFrom = cursor.from(); state.posTo = cursor.to();
});}
function clearSearch(cm) {cm.operation(function() {
Expand Down Expand Up @@ -108,6 +109,7 @@
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
}
cm.setSelection(cursor.from(), cursor.to());
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
confirmDialog(cm, doReplaceConfirm, "Replace?",
[function() {doReplace(match);}, advance]);
};
Expand Down
2 changes: 1 addition & 1 deletion addon/tern/tern.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
for (var file in perFile) {
var known = ts.docs[file], chs = perFile[file];;
if (!known) continue;
chs.sort(function(a, b) { return cmpPos(b, a); });
chs.sort(function(a, b) { return cmpPos(b.start, a.start); });
var origin = "*rename" + (++nextChangeOrig);
for (var i = 0; i < chs.length; ++i) {
var ch = chs[i];
Expand Down
Loading