Showing with 2,283 additions and 346 deletions.
  1. +15 −0 AUTHORS
  2. +30 −0 CHANGELOG.md
  3. +9 −2 addon/comment/comment.js
  4. +25 −38 addon/hint/show-hint.js
  5. +1 −1 addon/hint/sql-hint.js
  6. +2 −1 addon/lint/lint.js
  7. +24 −27 addon/search/match-highlighter.js
  8. +5 −2 addon/search/search.js
  9. +2 −2 addon/tern/tern.js
  10. +2 −2 bin/compress
  11. +55 −8 demo/complete.html
  12. +4 −0 doc/compress.html
  13. +36 −28 doc/manual.html
  14. +3 −1 doc/realworld.html
  15. +18 −0 doc/releases.html
  16. +2 −2 index.html
  17. +2 −0 keymap/sublime.js
  18. +20 −14 keymap/vim.js
  19. +9 −7 lib/codemirror.js
  20. +1 −1 mode/clike/clike.js
  21. +1 −1 mode/crystal/crystal.js
  22. +8 −8 mode/django/django.js
  23. +6 −6 mode/dtd/dtd.js
  24. +1 −1 mode/gfm/index.html
  25. +6 −0 mode/gfm/test.js
  26. +1 −1 mode/haml/haml.js
  27. +1 −1 mode/htmlembedded/index.html
  28. +5 −0 mode/index.html
  29. +1 −1 mode/markdown/markdown.js
  30. +3 −3 mode/markdown/test.js
  31. +1 −0 mode/mathematica/mathematica.js
  32. +44 −0 mode/mbox/index.html
  33. +129 −0 mode/mbox/mbox.js
  34. +6 −2 mode/meta.js
  35. +1 −1 mode/octave/index.html
  36. +5 −5 mode/pegjs/pegjs.js
  37. +1 −1 mode/perl/perl.js
  38. +204 −0 mode/powershell/index.html
  39. +396 −0 mode/powershell/powershell.js
  40. +72 −0 mode/powershell/test.js
  41. +1 −1 mode/properties/properties.js
  42. +1 −1 mode/puppet/puppet.js
  43. +1 −1 mode/python/index.html
  44. +20 −28 mode/python/python.js
  45. +30 −0 mode/python/test.js
  46. +81 −0 mode/sas/index.html
  47. +315 −0 mode/sas/sas.js
  48. +1 −1 mode/sparql/sparql.js
  49. +3 −2 mode/sql/index.html
  50. +10 −2 mode/sql/sql.js
  51. +78 −128 mode/tiddlywiki/tiddlywiki.js
  52. +1 −1 mode/verilog/index.html
  53. +1 −1 mode/verilog/test.js
  54. +1 −1 mode/verilog/verilog.js
  55. +1 −1 mode/vhdl/vhdl.js
  56. +71 −0 mode/webidl/index.html
  57. +195 −0 mode/webidl/webidl.js
  58. +1 −1 mode/xquery/xquery.js
  59. +87 −0 mode/yacas/index.html
  60. +204 −0 mode/yacas/yacas.js
  61. +1 −1 mode/yaml-frontmatter/index.html
  62. +1 −1 package.json
  63. +5 −0 test/index.html
  64. +12 −4 test/vim_test.js
  65. +4 −4 theme/icecoder.css
15 changes: 15 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Andre von Houck
Andrey Fedorov
Andrey Klyuchnikov
Andrey Lushnikov
Andrey Shchekin
Andy Joslin
Andy Kimball
Andy Li
Expand Down Expand Up @@ -75,9 +76,11 @@ benbro
Beni Cherniavsky-Paskin
Benjamin DeCoste
Ben Keen
Ben Miller
Ben Mosher
Bernhard Sirlinger
Bert Chang
Bharad
Billy Moon
binny
B Krishna Chaitanya
Expand Down Expand Up @@ -183,6 +186,7 @@ Gabriel Gheorghian
Gabriel Horner
Gabriel Nahmias
galambalazs
Gary Sheng
Gautam Mehta
Gavin Douglas
gekkoe
Expand All @@ -199,6 +203,7 @@ Gordon Smith
Grant Skinner
greengiant
Gregory Koberger
Grzegorz Mazur
Guillaume Massé
Guillaume Massé
guraga
Expand Down Expand Up @@ -230,6 +235,7 @@ Jakob Miland
Jakub Vrana
Jakub Vrána
James Campos
James Howard
James Thorne
Jamie Hill
Jan Jongboom
Expand All @@ -238,6 +244,7 @@ Jan Keromnes
Jan Odvarko
Jan Schär
Jan T. Sott
Jared Dean
Jared Forsyth
Jason
Jason Barnabe
Expand All @@ -256,6 +263,7 @@ Jim
JobJob
jochenberger
Jochen Berger
joelpinheiro
Johan Ask
John Connor
John Engler
Expand All @@ -271,6 +279,7 @@ Jon Sangster
Joost-Wim Boekesteijn
Joseph Pecoraro
Josh Cohen
Josh Soref
Joshua Newman
Josh Watzman
jots
Expand All @@ -297,6 +306,7 @@ Koh Zi Han, Cliff
komakino
Konstantin Lopuhin
koops
Kris Ciccarello
ks-ifware
kubelsmieci
KwanEsq
Expand All @@ -314,13 +324,15 @@ LM
lochel
Lorenzo Stoakes
Luciano Longo
Lu Fangjian
Luke Stagner
lynschinzer
M1cha
Madhura Jayaratne
Maksim Lin
Maksym Taran
Malay Majithia
Manideep
Manuel Rego Casasnovas
Marat Dreizin
Marcel Gerber
Expand Down Expand Up @@ -475,6 +487,7 @@ Scott Aikin
Scott Goodhew
Sebastian Zaha
Sergey Goder
Sergey Tselovalnikov
Se-Won Kim
shaund
shaun gilchrist
Expand Down Expand Up @@ -519,6 +532,7 @@ Thomas Schmid
Tim Alby
Tim Baumann
Timothy Farrell
Timothy Gu
Timothy Hatcher
TobiasBg
Tomas-A
Expand All @@ -531,6 +545,7 @@ Triangle717
Tristan Tarrant
TSUYUSATO Kitsune
twifkak
VapidWorx
Vestimir Markov
vf
Victor Bocharsky
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 5.14.0 (2016-04-20)

### Bugfixes

[`posFromIndex`](http://codemirror.net/doc/manual.html#posFromIndex) and [`indexFromPos`](http://codemirror.net/doc/manual.html#indexFromPos) now take [`lineSeparator`](http://codemirror.net/doc/manual.html#option_lineSeparator) into account.

[vim bindings](http://codemirror.net/demo/vim.html): Only call `.save()` when it is actually available.

[commend addon](http://codemirror.net/doc/manual.html#addon_comment): Be careful not to mangle multi-line strings.

[Python mode](http://codemirror.net/mode/python/index.html): Improve distinguishing of decorators from `@` operators.

[`findMarks`](http://codemirror.net/doc/manual.html#findMarks): No longer return marks that touch but don't overlap given range.

### New features

[vim bindings](http://codemirror.net/demo/vim.html): Add yank command.

[match-highlighter addon](http://codemirror.net/doc/manual.html#addon_match-highlighter): Add `trim` option to disable ignoring of whitespace.

[PowerShell mode](http://codemirror.net/mode/powershell/index.html): Added.

[Yacas mode](http://codemirror.net/mode/yacas/index.html): Added.

[Web IDL mode](http://codemirror.net/mode/webidl/index.html): Added.

[SAS mode](http://codemirror.net/mode/sas/index.html): Added.

[mbox mode](http://codemirror.net/mode/mbox/index.html): Added.

## 5.13.2 (2016-03-23)

### Bugfixes
Expand Down
11 changes: 9 additions & 2 deletions addon/comment/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@
}
});

// Rough heuristic to try and detect lines that are part of multi-line string
function probablyInsideString(cm, pos, line) {
return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
}

CodeMirror.defineExtension("lineComment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = self.getModeAt(from);
var firstLine = self.getLine(from.line);
if (firstLine == null || probablyInsideString(self, from, firstLine)) return;

var commentString = options.lineComment || mode.lineComment;
if (!commentString) {
if (options.blockCommentStart || mode.blockCommentStart) {
Expand All @@ -55,8 +63,7 @@
}
return;
}
var firstLine = self.getLine(from.line);
if (firstLine == null) return;

var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
var pad = options.padding == null ? " " : options.padding;
var blankLines = options.commentBlankLines || from.line == to.line;
Expand Down
63 changes: 25 additions & 38 deletions addon/hint/show-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,11 @@
},

update: function(first) {
if (this.tick == null) return;
if (!this.options.hint.async) {
this.finishUpdate(this.options.hint(this.cm, this.options), first);
} else {
var myTick = ++this.tick, self = this;
this.options.hint(this.cm, function(data) {
if (self.tick == myTick) self.finishUpdate(data, first);
}, this.options);
}
if (this.tick == null) return
var self = this, myTick = ++this.tick
fetchHints(this.options.hint, this.cm, this.options, function(data) {
if (self.tick == myTick) self.finishUpdate(data, first)
})
},

finishUpdate: function(data, first) {
Expand Down Expand Up @@ -362,40 +358,31 @@
return result
}

function fetchHints(hint, cm, options, callback) {
if (hint.async) {
hint(cm, callback, options)
} else {
var result = hint(cm, options)
if (result && result.then) result.then(callback)
else callback(result)
}
}

function resolveAutoHints(cm, pos) {
var helpers = cm.getHelpers(pos, "hint"), words
if (helpers.length) {
var async = false, resolved
for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
if (async) {
resolved = function(cm, callback, options) {
var app = applicableHelpers(cm, helpers)
function run(i, result) {
if (i == app.length) return callback(null)
var helper = app[i]
if (helper.async) {
helper(cm, function(result) {
if (result) callback(result)
else run(i + 1)
}, options)
} else {
var result = helper(cm, options)
if (result) callback(result)
else run(i + 1)
}
}
run(0)
}
resolved.async = true
} else {
resolved = function(cm, options) {
var app = applicableHelpers(cm, helpers)
for (var i = 0; i < app.length; i++) {
var cur = app[i](cm, options)
if (cur && cur.list.length) return cur
}
var resolved = function(cm, callback, options) {
var app = applicableHelpers(cm, helpers);
function run(i) {
if (i == app.length) return callback(null)
fetchHints(app[i], cm, options, function(result) {
if (result && result.list.length > 0) callback(result)
else run(i + 1)
})
}
run(0)
}
resolved.async = true
resolved.supportsSelection = true
return resolved
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
Expand Down
2 changes: 1 addition & 1 deletion addon/hint/sql-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}

function nameCompletion(cur, token, result, editor) {
// Try to complete table, colunm names and return start position of completion
// Try to complete table, column names and return start position of completion
var useBacktick = false;
var nameParts = [];
var start = token.start;
Expand Down
3 changes: 2 additions & 1 deletion addon/lint/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@

var annotations = [];
for (var i = 0; i < spans.length; ++i) {
annotations.push(spans[i].__annotation);
var ann = spans[i].__annotation;
if (ann) annotations.push(ann);
}
if (annotations.length) popupTooltips(annotations, e);
}
Expand Down
51 changes: 24 additions & 27 deletions addon/search/match-highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// highlighted only if the selected text is a word. showToken, when enabled,
// will cause the current token to be highlighted when nothing is selected.
// delay is used to specify how much time to wait, in milliseconds, before
// highlighting the matches. If annotateScrollbar is enabled, the occurances
// highlighting the matches. If annotateScrollbar is enabled, the occurences
// will be highlighted on the scrollbar via the matchesonscrollbar addon.

(function(mod) {
Expand All @@ -29,24 +29,20 @@
})(function(CodeMirror) {
"use strict";

var DEFAULT_MIN_CHARS = 2;
var DEFAULT_TOKEN_STYLE = "matchhighlight";
var DEFAULT_DELAY = 100;
var DEFAULT_WORDS_ONLY = false;
var defaults = {
style: "matchhighlight",
minChars: 2,
delay: 100,
wordsOnly: false,
annotateScrollbar: false,
showToken: false,
trim: true
}

function State(options) {
if (typeof options == "object") {
this.minChars = options.minChars;
this.style = options.style;
this.showToken = options.showToken;
this.delay = options.delay;
this.wordsOnly = options.wordsOnly;
this.annotateScrollbar = options.annotateScrollbar;
}
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
if (this.delay == null) this.delay = DEFAULT_DELAY;
if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
this.options = {}
for (var name in defaults)
this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
this.overlay = this.timeout = null;
this.matchesonscroll = null;
}
Expand All @@ -68,13 +64,13 @@
function cursorActivity(cm) {
var state = cm.state.matchHighlighter;
clearTimeout(state.timeout);
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
}

function addOverlay(cm, query, hasBoundary, style) {
var state = cm.state.matchHighlighter;
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
if (state.annotateScrollbar) {
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, true,
{className: "CodeMirror-selection-highlight-scrollbar"});
Expand All @@ -86,7 +82,7 @@
if (state.overlay) {
cm.removeOverlay(state.overlay);
state.overlay = null;
if (state.annotateScrollbar) {
if (state.matchesonscroll) {
state.matchesonscroll.clear();
state.matchesonscroll = null;
}
Expand All @@ -97,21 +93,22 @@
cm.operation(function() {
var state = cm.state.matchHighlighter;
removeOverlay(cm);
if (!cm.somethingSelected() && state.showToken) {
var re = state.showToken === true ? /[\w$]/ : state.showToken;
if (!cm.somethingSelected() && state.options.showToken) {
var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
while (start && re.test(line.charAt(start - 1))) --start;
while (end < line.length && re.test(line.charAt(end))) ++end;
if (start < end)
addOverlay(cm, line.slice(start, end), re, state.style);
addOverlay(cm, line.slice(start, end), re, state.options.style);
return;
}
var from = cm.getCursor("from"), to = cm.getCursor("to");
if (from.line != to.line) return;
if (state.wordsOnly && !isWord(cm, from, to)) return;
var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
if (selection.length >= state.minChars)
addOverlay(cm, selection, false, state.style);
if (state.options.wordsOnly && !isWord(cm, from, to)) return;
var selection = cm.getRange(from, to)
if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
if (selection.length >= state.options.minChars)
addOverlay(cm, selection, false, state.options.style);
});
}

Expand Down
Loading