Skip to content

Commit 4dd32df

Browse files
committed
fix: ux issues in project open workflows when path doesnt exist
1 parent 604f1cb commit 4dd32df

File tree

5 files changed

+56
-32
lines changed

5 files changed

+56
-32
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Welcome to Phoenix!
22

3-
**Website: https://phcode.dev**
3+
**Website: https://phcode.io**
44

5-
Phoenix is a modern open-source and [free software](https://www.gnu.org/philosophy/free-sw.en.html) code editor for the web, built for the browser.
5+
Phoenix is a modern open-source and [free software](https://www.gnu.org/philosophy/free-sw.en.html) text editor
6+
designed to make coding as simple and fun as playing a video game.
67

78
#### Code Guardian
89
[![Phoenix build verification](https://github.com/phcode-dev/phoenix/actions/workflows/build_verify.yml/badge.svg)](https://github.com/phcode-dev/phoenix/actions/workflows/build_verify.yml)
@@ -27,7 +28,7 @@ Phoenix is a modern open-source and [free software](https://www.gnu.org/philosop
2728
<img src="https://assets-global.website-files.com/607f4f6df411bd01527dc7d5/63bc40cd9d502eda8ea74ce7_Bugsnag%20Full%20Color.svg" alt="bugsnag" style="width:200px;"/>
2829
</a>
2930

30-
#### Development status: Stable/Release-candidate.
31+
#### Development status: Stable/Active.
3132

3233
![Screenshot from 2022-09-20 13-35-03](https://user-images.githubusercontent.com/5336369/191202975-6069d270-526a-443d-bd76-903353ae1222.png)
3334

src/extensionsIntegrated/CSSColorPreview/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ define(function (require, exports, module) {
230230
// Add listener for all editor changes
231231
EditorManager.on("activeEditorChange", function (event, newEditor, oldEditor) {
232232
if (newEditor && newEditor.isGutterActive(GUTTER_NAME)) {
233-
console.time("xxxxxxxxxxx");
234233
newEditor.off("cursorActivity.colorPreview");
235234
newEditor.on("cursorActivity.colorPreview", _cursorActivity);
236235
// Unbind the previous editor's change event if it exists
@@ -241,7 +240,6 @@ define(function (require, exports, module) {
241240
newEditor.on("change", onChanged);
242241
showColorMarks();
243242
_cursorActivity(null, newEditor);
244-
console.timeEnd("xxxxxxxxxxx");
245243
}
246244
});
247245

src/extensionsIntegrated/RecentProjects/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ define(function (require, exports, module) {
363363
}
364364
FileSystem.resolve(fullPath, function (err, item) {
365365
if (err) {
366-
recentProjects.splice(index, 1);
366+
removeFromRecentProject(fullPath);
367367
}
368368
reject();
369369
});

src/project/ProjectManager.js

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ define(function (require, exports, module) {
739739
entryType = isFolder ? Strings.DIRECTORY : Strings.FILE,
740740
title,
741741
message;
742+
path = Phoenix.app.getDisplayPath(path);
742743
path = StringUtils.breakableUrl(path);
743744

744745
switch (errType) {
@@ -1312,7 +1313,9 @@ define(function (require, exports, module) {
13121313
// which is now partially torn down (see #6574).
13131314
model.projectRoot = null;
13141315

1315-
_loadProject(getWelcomeProjectPath()).always(function () {
1316+
_loadProject(getPlaceholderProjectPath()).always(function () {
1317+
// we dont load any other project here as the saved project state will not get restored
1318+
// if we load an actual project at this time.
13161319
// Make sure not to reject the original deferred until the fallback
13171320
// project is loaded, so we don't violate expectations that there is always
13181321
// a current project before continuing after _loadProject().
@@ -1409,6 +1412,33 @@ define(function (require, exports, module) {
14091412
|| window.showOpenFilePicker; // fs access file picker
14101413
}
14111414

1415+
function _openProject(path, result) {
1416+
// Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
1417+
// actually close any documents even on success; we'll do that manually after the user also oks
1418+
// the folder-browse dialog.
1419+
CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true })
1420+
.done(function () {
1421+
if (path) {
1422+
// use specified path
1423+
_loadProject(path).then(result.resolve, result.reject);
1424+
} else {
1425+
// Pop up a folder browse dialog
1426+
FileSystem.showOpenDialog(false, true, Strings.CHOOSE_FOLDER, model.projectRoot.fullPath, null,
1427+
function (err, files) {
1428+
if (!err && files.length > 0) {
1429+
// Load the new project into the folder tree
1430+
_loadProject(files[0]).then(result.resolve, result.reject);
1431+
} else {
1432+
result.reject();
1433+
}
1434+
});
1435+
}
1436+
})
1437+
.fail(function () {
1438+
result.reject();
1439+
});
1440+
}
1441+
14121442
/**
14131443
* Open a new project. Currently, Brackets must always have a project open, so
14141444
* this method handles both closing the current project and opening a new project.
@@ -1422,7 +1452,7 @@ define(function (require, exports, module) {
14221452
*/
14231453
function openProject(path) {
14241454

1425-
var result = new $.Deferred();
1455+
const result = new $.Deferred();
14261456

14271457
if(!path && !_filePickerSupported()){
14281458
Dialogs.showModalDialog(
@@ -1434,29 +1464,24 @@ define(function (require, exports, module) {
14341464
return result.promise();
14351465
}
14361466

1437-
// Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
1438-
// actually close any documents even on success; we'll do that manually after the user also oks
1439-
// the folder-browse dialog.
1440-
CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true })
1441-
.done(function () {
1442-
if (path) {
1443-
// use specified path
1444-
_loadProject(path).then(result.resolve, result.reject);
1445-
} else {
1446-
// Pop up a folder browse dialog
1447-
FileSystem.showOpenDialog(false, true, Strings.CHOOSE_FOLDER, model.projectRoot.fullPath, null, function (err, files) {
1448-
if (!err && files.length > 0) {
1449-
// Load the new project into the folder tree
1450-
_loadProject(files[0]).then(result.resolve, result.reject);
1451-
} else {
1452-
result.reject();
1453-
}
1454-
});
1455-
}
1456-
})
1457-
.fail(function () {
1458-
result.reject();
1459-
});
1467+
if(!path){
1468+
_openProject(null, result);
1469+
return result.promise();
1470+
}
1471+
1472+
const rootEntry = FileSystem.getDirectoryForPath(path);
1473+
rootEntry.exists(function (err, exists) {
1474+
if (exists) {
1475+
_openProject(path, result);
1476+
return;
1477+
}
1478+
console.error("error project open path doesnt exist: ", path, err);
1479+
exports.trigger(EVENT_PROJECT_OPEN_FAILED, path);
1480+
_showErrorDialog(ERR_TYPE_LOADING_PROJECT_NATIVE, true, FileSystemError.NOT_FOUND, path)
1481+
.done(function () {
1482+
result.reject();
1483+
});
1484+
});
14601485

14611486
// if fail, don't open new project: user canceled (or we failed to save its unsaved changes)
14621487
return result.promise();

test/spec/CSSColorPreview-test-files/base.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
.class-6 {color: #ff0090 #802095 #954e3e #454e3e #150e3e;}
1717

1818
.class-vars {
19-
color: var(--slight-red); background-color: @blue-light; color: var(--red); background-color: @blue;
19+
color: var(--slight-red); background-color: @blue-light; color: var(--red); background-color: @blue; color: $white;
2020
}

0 commit comments

Comments
 (0)