This commit is contained in:
Colton Voege 2014-09-25 12:54:50 -04:00
commit a33cc3223a
9 changed files with 85820 additions and 85710 deletions

View file

@ -1,3 +1,9 @@
2014.09.21 Version 1.1.7
* Bugfixes
- fix several bugs in autocompletion
- workaround for inaccurate getBoundingClientRect on chrome 37
2014.08.17 Version 1.1.6 2014.08.17 Version 1.1.6
* Bugfixes * Bugfixes

2
build

@ -1 +1 @@
Subproject commit d6da1f204327cdebb02a6330ea7a3fa7ba989824 Subproject commit 17c02716b7f116c7920f8ef07c8c2b0e20d77ec0

View file

@ -74,7 +74,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
document.documentElement.appendChild(el); document.documentElement.appendChild(el);
var w = el.getBoundingClientRect().width; var w = el.getBoundingClientRect().width;
if (w > 0 && w < 1) if (w > 0 && w < 1)
CHAR_COUNT = 1; CHAR_COUNT = 50;
else else
CHAR_COUNT = 100; CHAR_COUNT = 100;
el.parentNode.removeChild(el); el.parentNode.removeChild(el);
@ -127,7 +127,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
}; };
this.$measureSizes = function() { this.$measureSizes = function() {
if (CHAR_COUNT === 1) { if (CHAR_COUNT === 50) {
var rect = null; var rect = null;
try { try {
rect = this.$measureNode.getBoundingClientRect(); rect = this.$measureNode.getBoundingClientRect();
@ -136,7 +136,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
}; };
var size = { var size = {
height: rect.height, height: rect.height,
width: rect.width width: rect.width / CHAR_COUNT
}; };
} else { } else {
var size = { var size = {

View file

@ -43,7 +43,7 @@ var HtmlCompletions = require("./html_completions").HtmlCompletions;
var WorkerClient = require("../worker/worker_client").WorkerClient; var WorkerClient = require("../worker/worker_client").WorkerClient;
// http://www.w3.org/TR/html5/syntax.html#void-elements // http://www.w3.org/TR/html5/syntax.html#void-elements
var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]; var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"]; var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
var Mode = function(options) { var Mode = function(options) {

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({ module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){ 1:[function(_dereq_,module,exports){
// This file was generated on Sun Mar 23, 2014 21:29 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net> // This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
// line 2 "JSONiqTokenizer.ebnf" // line 2 "JSONiqTokenizer.ebnf"
@ -4212,33 +4212,7 @@ JSONiqTokenizer.TOKEN =
'use strict'; 'use strict';
var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer; var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer;
var Lexer = _dereq_('./lexer').Lexer;
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: 'WS',
value: input.substring(begin, end)
});
};
};
var keys = 'NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|div|document|document-node|element|else|empty|empty-sequence|encoding|end|eq|every|except|exit|external|false|first|following|following-sibling|for|from|ft-option|function|ge|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|revalidation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit'.split('|'); var keys = 'NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|div|document|document-node|element|else|empty|empty-sequence|encoding|end|eq|every|except|exit|external|false|first|following|following-sibling|for|from|ft-option|function|ge|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|revalidation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit'.split('|');
var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; }); var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
@ -4368,7 +4342,40 @@ var Rules = {
] ]
}; };
exports.JSONiqLexer = function() { exports.JSONiqLexer = function(){ return new Lexer(JSONiqTokenizer, Rules); };
},
{"./JSONiqTokenizer":1,"./lexer":3}],
3:[function(_dereq_,module,exports){
'use strict';
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: 'WS',
value: input.substring(begin, end)
});
};
};
exports.Lexer = function(Tokenizer, Rules) {
this.tokens = []; this.tokens = [];
@ -4376,7 +4383,7 @@ exports.JSONiqLexer = function() {
state = (state === 'start' || !state) ? '["start"]' : state; state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state); var stack = JSON.parse(state);
var h = new TokenHandler(line); var h = new TokenHandler(line);
var tokenizer = new JSONiqTokenizer(line, h); var tokenizer = new Tokenizer(line, h);
var tokens = []; var tokens = [];
while(true) { while(true) {
@ -4440,7 +4447,7 @@ exports.JSONiqLexer = function() {
}; };
}; };
}, },
{"./JSONiqTokenizer":1}]},{},[2]) {}]},{},[2])
(2) (2)
}); });

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({ module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){ 1:[function(_dereq_,module,exports){
// This file was generated on Sun Mar 23, 2014 21:29 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net> // This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
// line 2 "XQueryTokenizer.ebnf" // line 2 "XQueryTokenizer.ebnf"
@ -4178,8 +4178,6 @@ XQueryTokenizer.TOKEN =
2:[function(_dereq_,module,exports){ 2:[function(_dereq_,module,exports){
'use strict'; 'use strict';
var XQueryTokenizer = _dereq_('./XQueryTokenizer').XQueryTokenizer;
var TokenHandler = function(code) { var TokenHandler = function(code) {
var input = code; var input = code;
this.tokens = []; this.tokens = [];
@ -4207,6 +4205,85 @@ var TokenHandler = function(code) {
}; };
}; };
exports.Lexer = function(Tokenizer, Rules) {
this.tokens = [];
this.getLineTokens = function(line, state) {
state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new Tokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer['parse_' + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === 'WS') {
tokens.push({
type: 'text',
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === 'function' && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === 'EOF') { break; }
if(token.value === '') { throw 'Encountered empty string lexical rule.'; }
tokens.push({
type: info === null ? 'text' : (typeof(info.token) === 'function' ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: 'text', value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(['start'])
};
} else {
throw e;
}
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
};
},
{}],
3:[function(_dereq_,module,exports){
'use strict';
var XQueryTokenizer = _dereq_('./XQueryTokenizer').XQueryTokenizer;
var Lexer = _dereq_('./lexer').Lexer;
var keys = 'after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position|strict'.split('|'); var keys = 'after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position|strict'.split('|');
var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; }); var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
@ -4337,114 +4414,9 @@ var Rules = {
] ]
}; };
exports.XQueryLexer = function() { exports.XQueryLexer = function(){ return new Lexer(XQueryTokenizer, Rules); };
this.tokens = [];
this.getLineTokens = function(line, state, row) {
state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new XQueryTokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer['parse_' + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === 'WS') {
tokens.push({
type: 'text',
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === 'function' && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === 'EOF') { break; }
if(token.value === '') { throw 'Encountered empty string lexical rule.'; }
tokens.push({
type: info === null ? 'text' : (typeof(info.token) === 'function' ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: 'text', value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(['start'])
};
} else {
throw e;
}
}
}
if(this.tokens[row] !== undefined) {
var cachedLine = this.lines[row];
var begin = sharedStart([line, cachedLine]);
var diff = cachedLine.length - line.length;
var idx = 0;
var col = 0;
for(var i = 0; i < tokens.length; i++) {
var t = tokens[i];
for(var j = 0; j < this.tokens[row].length; j++) {
var semanticToken = this.tokens[row][j];
if(
((col + t.value.length) <= begin.length && semanticToken.sc === col && semanticToken.ec === (col + t.value.length)) ||
(semanticToken.sc === (col + diff) && semanticToken.ec === (col + t.value.length + diff))
) {
idx = i;
t.type = semanticToken.type;
}
}
col += t.value.length;
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
function sharedStart(A) {
A = A.slice(0).sort();
var tem1, tem2, s;
tem1 = A[0];
s = tem1.length;
tem2 = A.pop();
while(s && tem2.indexOf(tem1) === -1) {
tem1 = tem1.substring(0, --s);
}
return tem1;
}
};
}, },
{"./XQueryTokenizer":1}]},{},[2]) {"./XQueryTokenizer":1,"./lexer":2}]},{},[3])
(2) (3)
}); });

View file

@ -816,10 +816,15 @@ var VirtualRenderer = function(container, theme) {
// lines may have been pushed down. If so, the first screen row will not // lines may have been pushed down. If so, the first screen row will not
// have changed, but the first actual row will. In that case, adjust // have changed, but the first actual row will. In that case, adjust
// scrollTop so that the cursor and onscreen content stays in the same place. // scrollTop so that the cursor and onscreen content stays in the same place.
// TODO: find a better way to handle this, that works non wrapped case and doesn't compute layerConfig twice
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) { if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
this.scrollTop = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight; var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
changes = changes | this.CHANGE_SCROLL; if (st > 0) {
changes |= this.$computeLayerConfig(); // this check is needed as a workaround for the documentToScreenRow returning -1 if document.length == 0
this.scrollTop = st;
changes = changes | this.CHANGE_SCROLL;
changes |= this.$computeLayerConfig();
}
} }
config = this.layerConfig; config = this.layerConfig;
// update scrollbar first to not lose scroll position when gutter calls resize // update scrollbar first to not lose scroll position when gutter calls resize

View file

@ -72,7 +72,7 @@ var deps = {
xqlint: { xqlint: {
path: "mode/xquery/xqlint.js", path: "mode/xquery/xqlint.js",
browserify: { browserify: {
npmModule: "git+https://github.com/wcandillon/xqlint.git#0.0.8", npmModule: "git+https://github.com/wcandillon/xqlint.git#master",
path: "xqlint/lib/xqlint.js", path: "xqlint/lib/xqlint.js",
exports: "XQLint" exports: "XQLint"
}, },