Skip to content

Commit

Permalink
Merge branch 'master' into v4
Browse files Browse the repository at this point in the history
Conflicts:
	lib/codemirror.js
  • Loading branch information
marijnh committed Mar 7, 2014
2 parents 8cbff72 + f2fc9c6 commit b4715b9
Show file tree
Hide file tree
Showing 16 changed files with 714 additions and 356 deletions.
127 changes: 0 additions & 127 deletions addon/hint/pig-hint.js

This file was deleted.

40 changes: 24 additions & 16 deletions addon/hint/sql-hint.js
Expand Up @@ -14,6 +14,7 @@
QUERY_DIV: ";",
ALIAS_KEYWORD: "AS"
};
var Pos = CodeMirror.Pos;

function getKeywords(editor) {
var mode = editor.doc.modeOption;
Expand Down Expand Up @@ -43,7 +44,7 @@
var cur = editor.getCursor();
var token = editor.getTokenAt(cur);
var string = token.string.substr(1);
var prevCur = CodeMirror.Pos(cur.line, token.start);
var prevCur = Pos(cur.line, token.start);
var table = editor.getTokenAt(prevCur).string;
if( !tables.hasOwnProperty( table ) ){
table = findTableByAlias(table, editor);
Expand Down Expand Up @@ -71,7 +72,7 @@
}

function convertNumberToCur( num ){
return CodeMirror.Pos(Math.floor( num ), +num.toString().split( '.' ).pop());
return Pos(Math.floor( num ), +num.toString().split( '.' ).pop());
}

function findTableByAlias(alias, editor) {
Expand All @@ -82,8 +83,8 @@
var table = "";
var separator = [];
var validRange = {
start: CodeMirror.Pos( 0, 0 ),
end: CodeMirror.Pos( editor.lastLine(), editor.getLineHandle( editor.lastLine() ).length )
start: Pos( 0, 0 ),
end: Pos( editor.lastLine(), editor.getLineHandle( editor.lastLine() ).length )
};

//add separator
Expand All @@ -92,8 +93,8 @@
separator.push( doc.posFromIndex(indexOfSeparator));
indexOfSeparator = fullQuery.indexOf( CONS.QUERY_DIV, indexOfSeparator+1);
}
separator.unshift( CodeMirror.Pos( 0, 0 ) );
separator.push( CodeMirror.Pos( editor.lastLine(), editor.getLineHandle( editor.lastLine() ).text.length ) );
separator.unshift( Pos( 0, 0 ) );
separator.push( Pos( editor.lastLine(), editor.getLineHandle( editor.lastLine() ).text.length ) );

//find valieRange
var prevItem = 0;
Expand Down Expand Up @@ -129,24 +130,31 @@
tables = (options && options.tables) || {};
keywords = keywords || getKeywords(editor);
var cur = editor.getCursor();
var token = editor.getTokenAt(cur);
var token = editor.getTokenAt(cur), end = token.end;
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) {
if (search.charAt(0) == ".") {
columnCompletion(result, editor);
if (!result.length) {
while (token.start && search.charAt(0) == ".") {
token = editor.getTokenAt(Pos(cur.line, token.start - 1));
search = token.string + search;
}
addMatches(result, search, tables,
function(w) {return w;});
}
} else {
addMatches(result, search, keywords,
function(w) {return w.toUpperCase();});
addMatches(result, search, tables,
function(w) {return w;});
}

return {
list: result,
from: CodeMirror.Pos(cur.line, token.start),
to: CodeMirror.Pos(cur.line, token.end)
from: Pos(cur.line, token.start),
to: Pos(cur.line, end)
};
}
CodeMirror.registerHelper("hint", "sql", sqlHint);
Expand Down
4 changes: 4 additions & 0 deletions addon/merge/merge.js
Expand Up @@ -89,6 +89,10 @@
}
dv.edit.on("change", change);
dv.orig.on("change", change);
dv.edit.on("markerAdded", set);
dv.edit.on("markerCleared", set);
dv.orig.on("markerAdded", set);
dv.orig.on("markerCleared", set);
dv.edit.on("viewportChange", set);
dv.orig.on("viewportChange", set);
update();
Expand Down
4 changes: 2 additions & 2 deletions addon/search/search.js
Expand Up @@ -28,7 +28,7 @@
if (stream.match(query)) return "searching";
while (!stream.eol()) {
stream.next();
if (startChar)
if (startChar && !caseInsensitive)
stream.skipTo(startChar) || stream.skipToEnd();
if (stream.match(query, false)) break;
}
Expand Down Expand Up @@ -77,7 +77,7 @@
if (!query || state.query) return;
state.query = parseQuery(query);
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
state.overlay = searchOverlay(state.query);
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
cm.addOverlay(state.overlay);
state.posFrom = state.posTo = cm.getCursor();
findNext(cm, rev);
Expand Down
3 changes: 3 additions & 0 deletions bin/release
Expand Up @@ -23,6 +23,9 @@ rewrite("lib/codemirror.js", function(lib) {
rewrite("package.json", function(pack) {
return pack.replace(/"version":"\d+\.\d+\.\d+"/, "\"version\":\"" + number + "\"");
});
rewrite("doc/manual.html", function(manual) {
return manual.replace(/>version \d+\.\d+\.\d+<\/span>/, ">version " + number + "</span>");
});

if (bumpOnly) process.exit(0);

Expand Down
1 change: 0 additions & 1 deletion doc/compress.html
Expand Up @@ -190,7 +190,6 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/addon/merge/merge.js">merge.js</option>
<option value="http://codemirror.net/addon/mode/multiplex.js">multiplex.js</option>
<option value="http://codemirror.net/addon/mode/overlay.js">overlay.js</option>
<option value="http://codemirror.net/addon/hint/pig-hint.js">pig-hint.js</option>
<option value="http://codemirror.net/addon/display/placeholder.js">placeholder.js</option>
<option value="http://codemirror.net/addon/hint/python-hint.js">python-hint.js</option>
<option value="http://codemirror.net/addon/display/rulers.js">rulers.js</option>
Expand Down
13 changes: 9 additions & 4 deletions doc/manual.html
Expand Up @@ -61,7 +61,10 @@
<article>

<section class=first id=overview>
<h2>User manual and reference guide</h2>
<h2 style="position: relative">
User manual and reference guide
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 4.0.0</span>
</h2>

<p>CodeMirror is a code-editor component that can be embedded in
Web pages. The core library provides <em>only</em> the editor
Expand Down Expand Up @@ -1257,6 +1260,8 @@ <h3 id="api_selection">Cursor and selection methods</h3>
the shift key, in that it will cause cursor movement and calls
to <a href="#extendSelection"><code>extendSelection</code></a>
to leave the selection anchor in place.</dd>
<dt id="getExtending"><code><strong>doc.getExtending</strong>() → boolean</code></dt>
<dd>Get the value of the 'extending' flag.</dd>

<dt id="hasFocus"><code><strong>cm.hasFocus</strong>() → boolean</code></dt>
<dd>Tells you whether the editor currently has focus.</dd>
Expand Down Expand Up @@ -2393,6 +2398,9 @@ <h2>Addons</h2>
<dd>Fired when a completion is selected. Passed the completion
value (string or object) and the DOM node that represents it
in the menu.</dd>
<dt><code><strong>"pick"</strong> (completion)</code></dt>
<dd>Fired when a completion is picked. Passed the completion value
(string or object).</dd>
<dt><code><strong>"close"</strong> ()</code></dt>
<dd>Fired when the completion is finished.</dd>
</dl>
Expand Down Expand Up @@ -2457,9 +2465,6 @@ <h2>Addons</h2>
<dt id="addon_sql-hint"><a href="../addon/hint/sql-hint.js"><code>hint/sql-hint.js</code></a></dt>
<dd>A simple SQL hinter. Defines <code>CodeMirror.hint.sql</code>.</dd>

<dt id="addon_pig-hint"><a href="../addon/hint/pig-hint.js"><code>hint/pig-hint.js</code></a></dt>
<dd>A simple hinter for <a href="../mode/pig/index.html">Pig Latin</a>. Defines <code>CodeMirror.hint.pig</code>.</dd>

<dt id="addon_match-highlighter"><a href="../addon/search/match-highlighter.js"><code>search/match-highlighter.js</code></a></dt>
<dd>Adds a <code>highlightSelectionMatches</code> option that
can be enabled to highlight all instances of a currently
Expand Down
2 changes: 1 addition & 1 deletion keymap/emacs.js
Expand Up @@ -204,7 +204,7 @@

function setMark(cm) {
cm.setCursor(cm.getCursor());
cm.setExtending(true);
cm.setExtending(!cm.getExtending());
cm.on("change", function() { cm.setExtending(false); });
}

Expand Down

0 comments on commit b4715b9

Please sign in to comment.