Skip to content

Commit 0c7ba3e

Browse files
committed
fix: number dials over - in class-name and some unrelated refactor
1 parent 4d2789f commit 0c7ba3e

File tree

4 files changed

+96
-108
lines changed

4 files changed

+96
-108
lines changed

src/brackets.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,7 @@ define(function (require, exports, module) {
426426
}
427427

428428
// Browser-hosted version may also have different CSS (e.g. since '#titlebar' is shown)
429-
if (brackets.inBrowser) {
430-
$body.addClass("in-browser");
431-
} else {
432-
$body.addClass("in-appshell");
433-
}
429+
$body.addClass("in-appshell");
434430

435431
$('#toolbar-extension-manager').prop('title', Strings.EXTENSION_MANAGER_TITLE);
436432
$('#update-notification').prop('title', Strings.UPDATE_NOTIFICATION_TOOLTIP);

src/editor/Editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ define(function (require, exports, module) {
15481548
// If we found a number, and it is withing the original max digit count, return the result
15491549
if (left !== right && digitCount !== maxDigitsOverflow) {
15501550
const text = str.substring(left, right);
1551-
if(text !== "."){
1551+
if(text !== "." && text !== "-"){
15521552
return {
15531553
text: str.substring(left, right),
15541554
startPos: {line: pos.line, ch: token.start + left},

src/project/ProjectManager.js

Lines changed: 73 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,77 @@ define(function (require, exports, module) {
11151115
});
11161116
}
11171117

1118+
function _loadProjectInternal(rootPath) {
1119+
const result = new $.Deferred();
1120+
const rootEntry = FileSystem.getDirectoryForPath(rootPath);
1121+
rootEntry.exists(function (err, exists) {
1122+
if (exists) {
1123+
var projectRootChanged = (!model.projectRoot || !rootEntry) ||
1124+
model.projectRoot.fullPath !== rootEntry.fullPath;
1125+
1126+
// Success!
1127+
var perfTimerName = PerfUtils.markStart("Load Project: " + rootPath);
1128+
1129+
_projectWarnedForTooManyFiles = false;
1130+
1131+
_setProjectRoot(rootEntry).always(function () {
1132+
model.setBaseUrl(PreferencesManager.getViewState("project.baseUrl", PreferencesManager.STATE_PROJECT_CONTEXT) || "");
1133+
1134+
if (projectRootChanged) {
1135+
_reloadProjectPreferencesScope();
1136+
PreferencesManager._setCurrentFile(rootPath);
1137+
}
1138+
_watchProjectRoot(rootPath);
1139+
1140+
// If this is the most current welcome project, record it. In future launches, we want
1141+
// to substitute the latest welcome project from the current build instead of using an
1142+
// outdated one (when loading recent projects or the last opened project).
1143+
if (rootPath === getWelcomeProjectPath()) {
1144+
addWelcomeProjectPath(rootPath);
1145+
}
1146+
1147+
if (projectRootChanged) {
1148+
// Allow asynchronous event handlers to finish before resolving result by collecting promises from them
1149+
exports.trigger(EVENT_PROJECT_OPEN, model.projectRoot);
1150+
result.resolve();
1151+
exports.trigger(EVENT_AFTER_PROJECT_OPEN, model.projectRoot);
1152+
} else {
1153+
exports.trigger(EVENT_PROJECT_REFRESH, model.projectRoot);
1154+
result.resolve();
1155+
}
1156+
let projectLoadTime = PerfUtils.addMeasurement(perfTimerName);
1157+
Metrics.valueEvent(Metrics.EVENT_TYPE.PERFORMANCE, "projectLoad",
1158+
"timeMs", Number(projectLoadTime));
1159+
});
1160+
} else {
1161+
console.error("error loading project");
1162+
exports.trigger(EVENT_PROJECT_OPEN_FAILED, rootPath);
1163+
_showErrorDialog(ERR_TYPE_LOADING_PROJECT_NATIVE, true, err || FileSystemError.NOT_FOUND, rootPath)
1164+
.done(function () {
1165+
// Reset _projectRoot to null so that the following _loadProject call won't
1166+
// run the 'beforeProjectClose' event a second time on the original project,
1167+
// which is now partially torn down (see #6574).
1168+
model.projectRoot = null;
1169+
1170+
// The project folder stored in preference doesn't exist, so load the default
1171+
// project directory.
1172+
// TODO (issue #267): When Brackets supports having no project directory
1173+
// defined this code will need to change
1174+
_getFallbackProjectPath().done(function (path) {
1175+
_loadProject(path).always(function () {
1176+
// Make sure not to reject the original deferred until the fallback
1177+
// project is loaded, so we don't violate expectations that there is always
1178+
// a current project before continuing after _loadProject().
1179+
result.reject();
1180+
});
1181+
});
1182+
});
1183+
}
1184+
});
1185+
1186+
return result.promise();
1187+
}
1188+
11181189
/**
11191190
* Loads the given folder as a project. Does NOT prompt about any unsaved changes - use openProject()
11201191
* instead to check for unsaved changes and (optionally) let the user choose the folder to open.
@@ -1126,8 +1197,6 @@ define(function (require, exports, module) {
11261197
* fails to load.
11271198
*/
11281199
function _loadProject(rootPath) {
1129-
var result = new $.Deferred(),
1130-
startLoad = new $.Deferred();
11311200

11321201
Metrics.valueEvent(Metrics.EVENT_TYPE.PROJECT, "Load",
11331202
isWelcomeProjectPath(rootPath) ? "default":"other", 1);
@@ -1155,81 +1224,8 @@ define(function (require, exports, module) {
11551224
exports.trigger(EVENT_PROJECT_CLOSE, model.projectRoot);
11561225
}
11571226

1158-
startLoad.resolve();
1159-
1160-
startLoad.done(function () {
1161-
// Populate file tree as long as we aren't running in the browser
1162-
if (!brackets.inBrowser) {
1163-
// Point at a real folder structure on local disk
1164-
var rootEntry = FileSystem.getDirectoryForPath(rootPath);
1165-
rootEntry.exists(function (err, exists) {
1166-
if (exists) {
1167-
var projectRootChanged = (!model.projectRoot || !rootEntry) ||
1168-
model.projectRoot.fullPath !== rootEntry.fullPath;
1169-
1170-
// Success!
1171-
var perfTimerName = PerfUtils.markStart("Load Project: " + rootPath);
1172-
1173-
_projectWarnedForTooManyFiles = false;
1174-
1175-
_setProjectRoot(rootEntry).always(function () {
1176-
model.setBaseUrl(PreferencesManager.getViewState("project.baseUrl", PreferencesManager.STATE_PROJECT_CONTEXT) || "");
1177-
1178-
if (projectRootChanged) {
1179-
_reloadProjectPreferencesScope();
1180-
PreferencesManager._setCurrentFile(rootPath);
1181-
}
1182-
_watchProjectRoot(rootPath);
1183-
1184-
// If this is the most current welcome project, record it. In future launches, we want
1185-
// to substitute the latest welcome project from the current build instead of using an
1186-
// outdated one (when loading recent projects or the last opened project).
1187-
if (rootPath === getWelcomeProjectPath()) {
1188-
addWelcomeProjectPath(rootPath);
1189-
}
1190-
1191-
if (projectRootChanged) {
1192-
// Allow asynchronous event handlers to finish before resolving result by collecting promises from them
1193-
exports.trigger(EVENT_PROJECT_OPEN, model.projectRoot);
1194-
result.resolve();
1195-
exports.trigger(EVENT_AFTER_PROJECT_OPEN, model.projectRoot);
1196-
} else {
1197-
exports.trigger(EVENT_PROJECT_REFRESH, model.projectRoot);
1198-
result.resolve();
1199-
}
1200-
let projectLoadTime = PerfUtils.addMeasurement(perfTimerName);
1201-
Metrics.valueEvent(Metrics.EVENT_TYPE.PERFORMANCE, "projectLoad",
1202-
"timeMs", Number(projectLoadTime));
1203-
});
1204-
} else {
1205-
console.error("error loading project");
1206-
exports.trigger(EVENT_PROJECT_OPEN_FAILED, rootPath);
1207-
_showErrorDialog(ERR_TYPE_LOADING_PROJECT_NATIVE, true, err || FileSystemError.NOT_FOUND, rootPath)
1208-
.done(function () {
1209-
// Reset _projectRoot to null so that the following _loadProject call won't
1210-
// run the 'beforeProjectClose' event a second time on the original project,
1211-
// which is now partially torn down (see #6574).
1212-
model.projectRoot = null;
1213-
1214-
// The project folder stored in preference doesn't exist, so load the default
1215-
// project directory.
1216-
// TODO (issue #267): When Brackets supports having no project directory
1217-
// defined this code will need to change
1218-
_getFallbackProjectPath().done(function (path) {
1219-
_loadProject(path).always(function () {
1220-
// Make sure not to reject the original deferred until the fallback
1221-
// project is loaded, so we don't violate expectations that there is always
1222-
// a current project before continuing after _loadProject().
1223-
result.reject();
1224-
});
1225-
});
1226-
});
1227-
}
1228-
});
1229-
}
1230-
});
1231-
1232-
return result.promise();
1227+
// Point at a real folder structure on local disk
1228+
return _loadProjectInternal(rootPath);
12331229
}
12341230

12351231
/**

src/utils/BuildInfoUtils.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,29 @@ define(function (require, exports, module) {
3737
* and loads the SHA from that file in turn.
3838
*/
3939
function _loadSHA(path, callback) {
40-
var result = new $.Deferred();
40+
const result = new $.Deferred();
4141

42-
if (brackets.inBrowser) {
43-
result.reject();
44-
} else {
45-
// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path
46-
// to a file in /refs which in turn contains the SHA
47-
var file = FileSystem.getFileForPath(path);
48-
FileUtils.readAsText(file).done(function (text) {
49-
if (text.indexOf("ref: ") === 0) {
50-
// e.g. "ref: refs/heads/branchname"
51-
var basePath = path.substr(0, path.lastIndexOf("/")),
52-
refRelPath = text.substr(5).trim(),
53-
branch = text.substr(16).trim();
42+
// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path
43+
// to a file in /refs which in turn contains the SHA
44+
const file = FileSystem.getFileForPath(path);
45+
FileUtils.readAsText(file).done(function (text) {
46+
if (text.indexOf("ref: ") === 0) {
47+
// e.g. "ref: refs/heads/branchname"
48+
const basePath = path.substr(0, path.lastIndexOf("/")),
49+
refRelPath = text.substr(5).trim(),
50+
branch = text.substr(16).trim();
5451

55-
_loadSHA(basePath + "/" + refRelPath, callback).done(function (data) {
56-
result.resolve({ branch: branch, sha: data.sha.trim() });
57-
}).fail(function () {
58-
result.resolve({ branch: branch });
59-
});
60-
} else {
61-
result.resolve({ sha: text });
62-
}
63-
}).fail(function () {
64-
result.reject();
65-
});
66-
}
52+
_loadSHA(basePath + "/" + refRelPath, callback).done(function (data) {
53+
result.resolve({ branch: branch, sha: data.sha.trim() });
54+
}).fail(function () {
55+
result.resolve({ branch: branch });
56+
});
57+
} else {
58+
result.resolve({ sha: text });
59+
}
60+
}).fail(function () {
61+
result.reject();
62+
});
6763

6864
return result.promise();
6965
}

0 commit comments

Comments
 (0)