Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gruehle committed Nov 7, 2013
2 parents 0fd2e14 + 4d6c73d commit dffad5f
Show file tree
Hide file tree
Showing 22 changed files with 316 additions and 96 deletions.
2 changes: 1 addition & 1 deletion src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ define(function LiveDevelopment(require, exports, module) {
// After (1) the interstitial page loads, (2) then browser navigation
// to the base URL is completed, and (3) the agents finish loading
// gather related documents and finally set status to STATUS_ACTIVE.
var doc = _getCurrentDocument(); // TODO: probably wrong...
var doc = _liveDocument.doc;

if (doc) {
var status = STATUS_ACTIVE,
Expand Down
29 changes: 13 additions & 16 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,18 @@ define(function (require, exports, module) {
if (indentAuto) {
var currentLength = line.length;
CodeMirror.commands.indentAuto(instance);
// If the amount of whitespace didn't change, insert another tab

// If the amount of whitespace and the cursor position didn't change, we must have
// already been at the correct indentation level as far as CM is concerned, so insert
// another tab.
if (instance.getLine(from.line).length === currentLength) {
insertTab = true;
to.ch = 0;
var newFrom = instance.getCursor(true),
newTo = instance.getCursor(false);
if (newFrom.line === from.line && newFrom.ch === from.ch &&
newTo.line === to.line && newTo.ch === to.ch) {
insertTab = true;
to.ch = 0;
}
}
} else if (instance.somethingSelected() && from.line !== to.line) {
CodeMirror.commands.indentMore(instance);
Expand Down Expand Up @@ -978,21 +986,10 @@ define(function (require, exports, module) {
return;
}

// Handle hiding a single blank line at the end specially by moving the "from" backwards
// to include the last newline. Otherwise CodeMirror doesn't hide anything in this case.
var hideFrom, inclusiveLeft = true;
if (from === to - 1 && from === this._codeMirror.lineCount() - 1 && this._codeMirror.getLine(from).length === 0) {
hideFrom = {line: from - 1, ch: this._codeMirror.getLine(from - 1).length};
// Allow the cursor to be set immediately before the hidden newline.
inclusiveLeft = false;
} else {
hideFrom = {line: from, ch: 0};
}

var value = this._codeMirror.markText(
hideFrom,
{line: from, ch: 0},
{line: to - 1, ch: this._codeMirror.getLine(to - 1).length},
{collapsed: true, inclusiveLeft: inclusiveLeft, inclusiveRight: true}
{collapsed: true, inclusiveLeft: true, inclusiveRight: true}
);

return value;
Expand Down
4 changes: 2 additions & 2 deletions src/editor/ImageViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ define(function (require, exports, module) {
$("#img-preview").on("load", function () {
// add dimensions and size
_naturalWidth = this.naturalWidth;
var dimensionString = _naturalWidth + " x " + this.naturalHeight + " " + Strings.UNIT_PIXELS;
var dimensionString = _naturalWidth + " × " + this.naturalHeight + " " + Strings.UNIT_PIXELS;
// get image size
var file = FileSystem.getFileForPath(fullPath);
file.stat(function (err, stat) {
if (err) {
$("#img-data").text(dimensionString);
$("#img-data").html(dimensionString);
} else {
var sizeString = "";
if (stat.size) {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ define(function (require, exports, module) {
$previewContainer.find(".image-preview > img").on("load", function () {
$previewContent
.append("<div class='img-size'>" +
this.naturalWidth + " x " + this.naturalHeight + " " + Strings.UNIT_PIXELS +
this.naturalWidth + " &times; " + this.naturalHeight + " " + Strings.UNIT_PIXELS +
"</div>"
);
$previewContainer.show();
Expand Down
22 changes: 17 additions & 5 deletions src/extensions/default/UrlCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ define(function (require, exports, module) {
// convert to doc relative path
var entryStr = entry.fullPath.replace(docDir, "");

// code hints show the same strings that are inserted into text,
// so strings in list will be encoded. wysiwyg, baby!
unfiltered.push(encodeURI(entryStr));
// code hints show the unencoded string so the
// choices are easier to read. The encoded string
// will still be inserted into the editor.
unfiltered.push(entryStr);
}
});

Expand Down Expand Up @@ -225,7 +226,7 @@ define(function (require, exports, module) {
};

/**
* Determines whether font hints are available in the current editor
* Determines whether url hints are available in the current editor
* context.
*
* @param {Editor} editor
Expand Down Expand Up @@ -361,7 +362,7 @@ define(function (require, exports, module) {
};

/**
* Returns a list of availble font hints, if possible, for the current
* Returns a list of available url hints, if possible, for the current
* editor context.
*
* @return {jQuery.Deferred|{
Expand Down Expand Up @@ -504,6 +505,10 @@ define(function (require, exports, module) {
*/
UrlCodeHints.prototype.insertHint = function (completion) {
var mode = this.editor.getModeForSelection();

// Encode the string just prior to inserting the hint into the editor
completion = encodeURI(completion);

if (mode === "html") {
return this.insertHtmlHint(completion);
} else if (mode === "css") {
Expand Down Expand Up @@ -754,4 +759,11 @@ define(function (require, exports, module) {
// For unit testing
exports.hintProvider = urlHints;
});

$(ProjectManager).on("projectFilesChange", function (event, projectRoot) {

This comment has been minimized.

Copy link
@peterflynn

peterflynn Nov 7, 2013

Member

This change snuck in from master: the "projectFilesChange" event no longer exists

This comment has been minimized.

Copy link
@iwehrman

iwehrman Nov 7, 2013

Contributor

Fixed.

// Cache may or may not be stale. Main benefit of cache is to limit async lookups
// during typing. File tree updates cannot happen during typing, so it's probably
// not worth determining whether cache may still be valid. Just delete it.
exports.hintProvider.cachedHints = null;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
float: left;
padding-left: 20px;
width: 35%;
word-break: break-all;
word-wrap: break-word;
-webkit-hyphens: auto;
hyphens: auto;

Expand Down
1 change: 1 addition & 0 deletions src/filesystem/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ define(function (require, exports, module) {
this._watchEntry(entry, watchedRoot, function (err) {
if (err) {
console.warn("Failed to watch root: ", entry.fullPath, err);
callback(err);
return;
}

Expand Down
90 changes: 70 additions & 20 deletions src/filesystem/FileSystemEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
define(function (require, exports, module) {
"use strict";

var FileSystemError = require("filesystem/FileSystemError");

var VISIT_DEFAULT_MAX_DEPTH = 10,
VISIT_DEFAULT_MAX_ENTRIES = 30000;

/* Counter to give every entry a unique id */
var nextId = 0;

Expand Down Expand Up @@ -231,39 +236,36 @@ define(function (require, exports, module) {
};

/**
* Visit this entry and its descendents with the supplied visitor function.
* Private helper function for FileSystemEntry.visit that requires sanitized options.
*
* @private
* @param {function(FileSystemEntry): boolean} visitor - A visitor function, which is
* applied to descendent FileSystemEntry objects. If the function returns false for
* a particular Directory entry, that directory's descendents will not be visited.
* @param {{failFast: boolean=, maxDepth: number=}=} options - An optional set of options.
* @param {{failFast: boolean, maxDepth: number, maxEntriesCounter: {value: number}}} options
* @param {function(?string)=} callback Callback with single "error" parameter.
*/
FileSystemEntry.prototype.visit = function (visitor, options, callback) {
var DEFAULT_MAX_DEPTH = 100;
FileSystemEntry.prototype._visitHelper = function (visitor, options, callback) {
var failFast = options.failFast,
maxDepth = options.maxDepth,
maxEntriesCounter = options.maxEntriesCounter;

if (typeof options === "function") {
callback = options;
options = {};
} else if (options === undefined) {
options = {};
if (maxEntriesCounter.value-- <= 0 || maxDepth-- < 0) {
callback(failFast ? FileSystemError.TOO_MANY_ENTRIES : null);
return;
}

callback = callback || function () {};

var maxDepth = typeof options.maxDepth === "number" ? options.maxDepth : DEFAULT_MAX_DEPTH,
continueTraversal = visitor(this) && maxDepth-- > 0;

if (this.isFile || !continueTraversal) {
if (!visitor(this) || this.isFile) {
callback(null);
return;
}

this.getContents(function (err, entries) {
var counter = entries ? entries.length : 0,
newOptions = {
nextOptions = {
failFast: failFast,
maxDepth: maxDepth,
failFast: options.maxDepth
maxEntriesCounter: maxEntriesCounter
};

if (err || counter === 0) {
Expand All @@ -272,21 +274,69 @@ define(function (require, exports, module) {
}

entries.forEach(function (entry) {
entry.visit(visitor, newOptions, function (err) {
if (err && options.failFast) {
entry._visitHelper(visitor, nextOptions, function (err) {
if (err && failFast) {
counter = 0;
callback(err);
return;
}

if (--counter === 0) {
callback(options.failFast ? err : null);
callback(failFast ? err : null);
}
});
});
}.bind(this));
};

/**
* Visit this entry and its descendents with the supplied visitor function.
*
* @param {function(FileSystemEntry): boolean} visitor - A visitor function, which is
* applied to descendent FileSystemEntry objects. If the function returns false for
* a particular Directory entry, that directory's descendents will not be visited.
* @param {{failFast: boolean=, maxDepth: number=, maxEntries: number=}=} options - An optional set of options.
* @param {function(?string)=} callback Callback with single "error" parameter.
*/
FileSystemEntry.prototype.visit = function (visitor, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
} else if (options === undefined) {
options = {};
}

if (options.failFast === undefined) {
options.failFast = false;
}

if (options.maxDepth === undefined) {
options.maxDepth = VISIT_DEFAULT_MAX_DEPTH;
}

if (options.maxEntries === undefined) {
options.maxEntries = VISIT_DEFAULT_MAX_ENTRIES;
}

options.maxEntriesCounter = { value: options.maxEntries };

this._visitHelper(visitor, options, function (err) {
if (callback) {
if (err) {
callback(err);
return;
}

if (options.maxEntriesCounter.value < 0) {
callback(FileSystemError.TOO_MANY_ENTRIES);
return;
}

callback(null);
}
});
};

// Export this class
module.exports = FileSystemEntry;
});
1 change: 1 addition & 0 deletions src/filesystem/FileSystemError.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ define(function (require, exports, module) {
NOT_READABLE : "NotReadable",
NOT_WRITABLE : "NotWritable",
OUT_OF_SPACE : "OutOfSpace",
TOO_MANY_ENTRIES : "TooManyEntries",
ALREADY_EXISTS : "AlreadyExists"
// FUTURE: Add remote connection errors: timeout, not logged in, connection err, etc.
};
Expand Down
6 changes: 1 addition & 5 deletions src/htmlContent/contributors-list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{{#.}}
<a href="{{html_url}}" title="{{login}} - {{html_url}}">
<img src="{{avatar_url}}" alt="{{login}}" width="30" height="30" />
</a>
{{/.}}
{{#.}}<a href="{{html_url}}" title="{{login}} - {{html_url}}"><img src="{{avatar_url}}" alt="{{login}}" width="30" height="30" /></a>{{/.}}
13 changes: 3 additions & 10 deletions src/language/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"css": {
"name": "CSS",
"mode": "css",
"fileExtensions": ["css"],
"fileExtensions": ["css", "css.erb"],
"blockComment": ["/*", "*/"]
},

Expand All @@ -43,17 +43,10 @@
"ejs": {
"name": "EJS",
"mode": ["htmlembedded", "application/x-ejs"],
"fileExtensions": ["ejs"],
"fileExtensions": ["ejs", "dust"],
"blockComment": ["<!--", "-->"]
},

"dust": {
"name": "Dust.js",
"mode": ["htmlembedded", "application/x-ejs"],
"fileExtensions": ["dust"],
"blockComment": ["<!--", "-->"]
},

"erb_html": {
"name": "Embedded Ruby",
"mode": ["htmlembedded", "application/x-erb"],
Expand Down Expand Up @@ -122,7 +115,7 @@
"csharp": {
"name": "C#",
"mode": ["clike", "text/x-csharp"],
"fileExtensions": ["cs", "cshtml", "asax", "ashx"],
"fileExtensions": ["cs", "asax", "ashx"],
"blockComment": ["/*", "*/"],
"lineComment": ["//"]
},
Expand Down
13 changes: 7 additions & 6 deletions src/nls/fa-ir/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ define({
"CMD_FILE_SAVE_ALL" : "ذخیره همه",
"CMD_FILE_SAVE_AS" : "ذخیره همه\u2026",
"CMD_LIVE_FILE_PREVIEW" : "پیش نمایش زنده",
"CMD_LIVE_HIGHLIGHT" : "نشانه گذاری پیش نمایش",
"CMD_PROJECT_SETTINGS" : "تنظیمات پروژه\u2026",
"CMD_FILE_RENAME" : "تغییر نام",
"CMD_FILE_DELETE" : "حذف",
Expand All @@ -226,9 +225,9 @@ define({
"CMD_FIND_NEXT" : "بعدی",
"CMD_FIND_PREVIOUS" : "قبلی",
"CMD_REPLACE" : "جستجو و جایگزینی",
"CMD_INDENT" : "برجسته سازی",
"CMD_UNINDENT" : "حذف برجستگی",
"CMD_DUPLICATE" : "دو نسخه کردن",
"CMD_INDENT" : "یک فاصله از چپ",
"CMD_UNINDENT" : "حذف یک فاصله از جپ",
"CMD_DUPLICATE" : "دونسخه کردن خط",
"CMD_DELETE_LINES" : "حذف خط",
"CMD_COMMENT" : "تعویض خط به نظر",
"CMD_BLOCK_COMMENT" : "تعویض نظر به خط",
Expand All @@ -251,6 +250,8 @@ define({
"CMD_TOGGLE_LINE_NUMBERS" : "شماره گذاری خط ها",
"CMD_TOGGLE_ACTIVE_LINE" : "نشانه گذاری خط فعال",
"CMD_TOGGLE_WORD_WRAP" : "شکستن عبارات طولانی",
"CMD_LIVE_HIGHLIGHT" : "نشانه گذاری پیش نمایش",
"CMD_VIEW_TOGGLE_INSPECTION" : "نشانه گذاری فایل های تغییر یافته برای ذخیره سازی",
"CMD_SORT_WORKINGSET_BY_ADDED" : "مرتب سازی بر اساس ترتیب افزودن",
"CMD_SORT_WORKINGSET_BY_NAME" : "مرتب سازی بر اساس نام",
"CMD_SORT_WORKINGSET_BY_TYPE" : "مرتب سازی بر اساس نوع",
Expand Down Expand Up @@ -409,7 +410,7 @@ define({
"CMD_REFRESH_WINDOW" : "بارگذاری مجدد براکتس",
"CMD_NEW_BRACKETS_WINDOW" : "یک پنجره جدید از براکتس باز کنید",
"CMD_SWITCH_LANGUAGE" : "انتخاب زبان",
"CMD_RUN_UNIT_TESTS" : "اجرای test",
"CMD_RUN_UNIT_TESTS" : "برسی برای اجرا",
"CMD_SHOW_PERF_DATA" : "نمایش داده های عملکردی",
"CMD_ENABLE_NODE_DEBUGGER" : "فعال سازی اشکال زدای گرهی",
"CMD_LOG_NODE_STATE" : "ورود گره به حالت کنسول",
Expand All @@ -433,7 +434,7 @@ define({
"LOCALE_IT" : "Italian",
"LOCALE_JA" : "Japanese",
"LOCALE_NB" : "Norwegian",
"LOCALE_fa_ir" : "Persian-پارسی",
"LOCALE_FA_IR" : "Persian-پارسی",
"LOCALE_PL" : "Polish",
"LOCALE_PT_BR" : "Portuguese, Brazil",
"LOCALE_PT_PT" : "Portuguese",
Expand Down
1 change: 1 addition & 0 deletions src/nls/fr/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ define({
"LOCALE_IT": "Italien",
"LOCALE_JA": "Japonais",
"LOCALE_NB": "Norvégien",
"LOCALE_FA_IR": "Persan/Farsi",
"LOCALE_PL": "Polonais",
"LOCALE_PT_BR": "Portugais (Brésil)",
"LOCALE_PT_PT": "Portugais",
Expand Down
Loading

0 comments on commit dffad5f

Please sign in to comment.