Skip to content

Commit f20b8f1

Browse files
author
Joseph Atkins-Turkish
committed
Cleanup and fixes
1 parent 0330e60 commit f20b8f1

File tree

4 files changed

+31
-32
lines changed

4 files changed

+31
-32
lines changed

ide/static/ide/css/ide.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,16 +1137,12 @@ span.cm-autofilled-end {
11371137
}
11381138

11391139
.fuzzy-subheader {
1140-
/*background-color: #222;*/
11411140
font-weight: bold;
1142-
color: #555;
1141+
color: #666;
11431142
font-variant: small-caps;
11441143
margin-left: 1em;
11451144

11461145
}
1147-
.fuzzy-subheader::before {
1148-
/*content: '-- ';*/
1149-
}
11501146

11511147
.fuzzy-hint {
11521148
opacity: 0.5;
@@ -1159,7 +1155,6 @@ span.cm-autofilled-end {
11591155
}
11601156

11611157
#fuzzy-results > div {
1162-
11631158
line-height: 28px;
11641159
cursor: pointer;
11651160
cursor: hand;

ide/static/ide/js/editor.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ CloudPebble.Editor = (function() {
240240
code_mirror.on('shown', function() {
241241
is_autocompleting = true;
242242
});
243-
current_editor = code_mirror;
244243

245244
// The browser should probably do this without our help. Sometimes Safari doesn't.
246245
$(document).click(function(e) {
@@ -482,20 +481,30 @@ CloudPebble.Editor = (function() {
482481
alert(gettext(interpolate("Failed to reload file. %s", [error])));
483482
});
484483
};
484+
485+
function set_save_shortcut() {
486+
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
487+
"PlatformCmd-S": save
488+
});
489+
}
490+
set_save_shortcut();
485491

486492
CloudPebble.Sidebar.SetActivePane(pane, {
487493
id: 'source-' + file.id,
488494
onRestore: function() {
495+
current_editor = code_mirror;
489496
code_mirror.refresh();
490497
_.defer(function() { code_mirror.focus(); });
491498
check_safe();
499+
set_save_shortcut();
492500
refresh_ib();
493501
},
494502
onSuspend: function() {
495503
if (is_fullscreen) {
496504
fullscreen(code_mirror, false);
497505
resume_fullscreen = true;
498506
}
507+
current_editor = null;
499508
},
500509
onDestroy: function() {
501510
if(!was_clean) {
@@ -520,7 +529,7 @@ CloudPebble.Editor = (function() {
520529
CloudPebble.Sidebar.ClearIcon('source-' + file.id);
521530
};
522531

523-
var save = function() {
532+
function save() {
524533
// Make sure we're up to date with whatever changed in IB.
525534
if(ib_showing) {
526535
var content = code_mirror.getValue();
@@ -766,6 +775,7 @@ CloudPebble.Editor = (function() {
766775
var error_box = $('<div class="alert alert-error"></div>');
767776
error_box.text(interpolate(gettext("Something went wrong: %s"), [error.message]));
768777
CloudPebble.Sidebar.SetActivePane(error_box, {id: ''});
778+
throw error;
769779
}).finally(function() {
770780
CloudPebble.ProgressBar.Hide();
771781
});
@@ -835,7 +845,7 @@ CloudPebble.Editor = (function() {
835845
var codemirror_commands = [
836846
{command: 'indentAuto', refocus: true},
837847
{command: 'toggleComment', hint: 'Cmd-/ or Ctrl-/', refocus: true},
838-
'find', 'replace', 'indentMore', 'indentLess'
848+
'find', 'replace', 'indentMore', 'indentLess', 'save', 'saveAll'
839849
];
840850

841851
_.each(codemirror_commands, function(entry) {
@@ -848,26 +858,10 @@ CloudPebble.Editor = (function() {
848858
local_commands[name].hint = !!entry.hint ? entry.hint : CloudPebble.GlobalShortcuts.GetShortcutForCommand(command);
849859
});
850860

851-
// local_commands[gettext('Auto Indent')] = function() {
852-
// current_editor.execCommand('indentAuto');
853-
// current_editor.focus();
854-
// };
855-
// local_commands[gettext('Auto Indent')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('indentAuto');
856-
// local_commands[gettext('Find')] = function() {
857-
// current_editor.execCommand('find');
858-
// };
859-
// local_commands[gettext('Find')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('find');
860-
861-
862861
CloudPebble.FuzzyPrompt.AddCommands(gettext('File'), local_commands, function() {
863862
return (!!current_editor);
864863
});
865864

866-
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
867-
save: function() {
868-
save().catch(alert);
869-
}
870-
});
871865

872866
CloudPebble.FuzzyPrompt.AddCommands(gettext('Actions'), global_commands);
873867

ide/static/ide/js/fuzzyprompt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CloudPebble.FuzzyPrompt = (function() {
3333
var options = {
3434
caseSensitive: false,
3535
sortFn: function(a, b) {
36-
return (a.score === b.score) ? a.item.name.localeCompare(b) : a.score - b.score;
36+
return (a.score === b.score) ? a.item.name.localeCompare(b.item.name) : a.score - b.score;
3737
},
3838
shouldSort: true,
3939
threshold: 0.5,

ide/static/ide/js/resources.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,28 @@ CloudPebble.Resources = (function() {
470470
if(list_entry) {
471471
list_entry.addClass('active');
472472
}
473-
473+
function set_save_shortcut() {
474+
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
475+
"PlatformCmd-S": save
476+
});
477+
}
478+
set_save_shortcut();
474479
CloudPebble.Sidebar.SetActivePane(pane, {
475480
id: 'resource-' + resource.id,
476-
onRestore: _.partial(restore_pane, pane)
481+
onRestore: function() {
482+
restore_pane(pane);
483+
set_save_shortcut();
484+
},
485+
onSuspend: function() {
486+
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
487+
"PlatformCmd-S": function() {return false;}
488+
});
489+
}
477490
});
478491
pane.find('#edit-resource-type').val(resource.kind).attr('disabled', 'disabled');
479492
pane.find('#edit-resource-type').change();
480493

481-
var save = function(e) {
494+
function save(e) {
482495
if (e) e.preventDefault();
483496
process_resource_form(form, false, resource.file_name, "/ide/project/" + PROJECT_ID + "/resource/" + resource.id + "/update").then(function(data) {
484497
delete project_resources[resource.file_name];
@@ -764,9 +777,6 @@ CloudPebble.Resources = (function() {
764777
}).init();
765778

766779
form.submit(save);
767-
CloudPebble.GlobalShortcuts.SetShortcutHandlers({
768-
save: save
769-
});
770780

771781
restore_pane(pane);
772782
}).finally(function() {

0 commit comments

Comments
 (0)