Merge pull request #4230 from dloverin/partial-update-fix

Ignore empty lines when finding a fragment for partial updates.
This commit is contained in:
Erik Tierney committed 2013-06-17 08:10:21 -07:00
commit 7fbcc4a932
2 files changed
+21 -9

No files matched your search

@@ -132,6 +132,7 @@ define(function (require, exports, module) {
} catch (e) {
// continue with null configObj which will result in
// default settings.
console.log("Error parsing preference file: " + path);
}
preferences = new Preferences(configObj);
deferredPreferences.resolve();
@@ -504,12 +505,14 @@ define(function (require, exports, module) {
document = session.editor.document,
p,
min,
indent;
indent,
line;
// expand range backwards
for (p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) {
var line = session.getLine(p),
fn = line.search(/\bfunction\b/);
for (p = start.line - 1, min = Math.max(0, p - 100); p >= min; --p) {
line = session.getLine(p);
var fn = line.search(/\bfunction\b/);
if (fn >= 0) {
indent = CodeMirror.countColumn(line, null, tabSize);
if (minIndent === null || minIndent > indent) {
@@ -529,16 +532,23 @@ define(function (require, exports, module) {
minLine = min;
}
var max = Math.min(cm.lastLine(), start.line + 90);
var max = Math.min(cm.lastLine(), start.line + 100),
endCh = 0;
for (endLine = start.line + 1; endLine < max; ++endLine) {
indent = CodeMirror.countColumn(cm.getLine(endLine), null, tabSize);
if (indent <= minIndent) {
break;
line = cm.getLine(endLine);
if (line.length > 0) {
indent = CodeMirror.countColumn(line, null, tabSize);
if (indent <= minIndent) {
endCh = line.length;
break;
}
}
}
var from = {line: minLine, ch: 0},
to = {line: endLine, ch: 0};
to = {line: endLine, ch: endCh};
return {type: MessageIds.TERN_FILE_INFO_TYPE_PART,
name: document.file.fullPath,
@@ -241,6 +241,7 @@ define(function (require, exports, module) {
function hintsPresentExact(hintObj, expectedHints) {
_waitForHints(hintObj, function (hintList) {
expect(hintList).not.toBeNull();
expect(hintList.length).toBe(expectedHints.length);
expectedHints.forEach(function (expectedHint, index) {
expect(hintList[index].data("token").value).toBe(expectedHint);
});
@@ -1224,6 +1225,7 @@ define(function (require, exports, module) {
describe("JavaScript Code Hinting without modules", function () {
var testPath = extensionPath + "/unittest-files/non-module-test-files/app.js";
ScopeManager.handleProjectOpen(extensionPath + "/unittest-files/non-module-test-files/");
beforeEach(function () {
setupTest(testPath, true);
});