diff --git a/ide/static/ide/css/ide.css b/ide/static/ide/css/ide.css index 22b40e89..ce5638fe 100644 --- a/ide/static/ide/css/ide.css +++ b/ide/static/ide/css/ide.css @@ -1137,16 +1137,12 @@ span.cm-autofilled-end { } .fuzzy-subheader { - /*background-color: #222;*/ font-weight: bold; - color: #555; + color: #666; font-variant: small-caps; margin-left: 1em; } -.fuzzy-subheader::before { - /*content: '-- ';*/ -} .fuzzy-hint { opacity: 0.5; @@ -1159,7 +1155,6 @@ span.cm-autofilled-end { } #fuzzy-results > div { - line-height: 28px; cursor: pointer; cursor: hand; diff --git a/ide/static/ide/js/editor.js b/ide/static/ide/js/editor.js index 9a46216b..48484d1e 100644 --- a/ide/static/ide/js/editor.js +++ b/ide/static/ide/js/editor.js @@ -240,7 +240,6 @@ CloudPebble.Editor = (function() { code_mirror.on('shown', function() { is_autocompleting = true; }); - current_editor = code_mirror; // The browser should probably do this without our help. Sometimes Safari doesn't. $(document).click(function(e) { @@ -486,6 +485,7 @@ CloudPebble.Editor = (function() { CloudPebble.Sidebar.SetActivePane(pane, { id: 'source-' + file.id, onRestore: function() { + current_editor = code_mirror; code_mirror.refresh(); _.defer(function() { code_mirror.focus(); }); check_safe(); @@ -496,6 +496,7 @@ CloudPebble.Editor = (function() { fullscreen(code_mirror, false); resume_fullscreen = true; } + current_editor = null; }, onDestroy: function() { if(!was_clean) { @@ -835,7 +836,7 @@ CloudPebble.Editor = (function() { var codemirror_commands = [ {command: 'indentAuto', refocus: true}, {command: 'toggleComment', hint: 'Cmd-/ or Ctrl-/', refocus: true}, - 'find', 'replace', 'indentMore', 'indentLess' + 'find', 'replace', 'indentMore', 'indentLess', 'save', 'saveAll' ]; _.each(codemirror_commands, function(entry) { @@ -848,26 +849,10 @@ CloudPebble.Editor = (function() { local_commands[name].hint = !!entry.hint ? entry.hint : CloudPebble.GlobalShortcuts.GetShortcutForCommand(command); }); - // local_commands[gettext('Auto Indent')] = function() { - // current_editor.execCommand('indentAuto'); - // current_editor.focus(); - // }; - // local_commands[gettext('Auto Indent')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('indentAuto'); - // local_commands[gettext('Find')] = function() { - // current_editor.execCommand('find'); - // }; - // local_commands[gettext('Find')].hint = CloudPebble.GlobalShortcuts.GetShortcutForCommand('find'); - - CloudPebble.FuzzyPrompt.AddCommands(gettext('File'), local_commands, function() { return (!!current_editor); }); - CloudPebble.GlobalShortcuts.SetShortcutHandlers({ - save: function() { - save().catch(alert); - } - }); CloudPebble.FuzzyPrompt.AddCommands(gettext('Actions'), global_commands); diff --git a/ide/static/ide/js/fuzzyprompt.js b/ide/static/ide/js/fuzzyprompt.js index c1388523..8b3cea06 100644 --- a/ide/static/ide/js/fuzzyprompt.js +++ b/ide/static/ide/js/fuzzyprompt.js @@ -33,7 +33,7 @@ CloudPebble.FuzzyPrompt = (function() { var options = { caseSensitive: false, sortFn: function(a, b) { - return (a.score === b.score) ? a.item.name.localeCompare(b) : a.score - b.score; + return (a.score === b.score) ? a.item.name.localeCompare(b.item.name) : a.score - b.score; }, shouldSort: true, threshold: 0.5, diff --git a/ide/static/ide/js/global_shortcuts.js b/ide/static/ide/js/global_shortcuts.js index dccf6163..fe6b04cc 100644 --- a/ide/static/ide/js/global_shortcuts.js +++ b/ide/static/ide/js/global_shortcuts.js @@ -62,6 +62,10 @@ CloudPebble.GlobalShortcuts = (function () { } }); }, + RemoveShortcutHandler: function(key) { + var shortcut = shortcut_for_command(key); + delete global_shortcuts[shortcut]; + }, GetShortcuts: function() { return global_shortcuts; }, diff --git a/ide/static/ide/js/resources.js b/ide/static/ide/js/resources.js index 21263df1..cbfde4a1 100644 --- a/ide/static/ide/js/resources.js +++ b/ide/static/ide/js/resources.js @@ -470,15 +470,26 @@ CloudPebble.Resources = (function() { if(list_entry) { list_entry.addClass('active'); } - + function set_save_shortcut() { + CloudPebble.GlobalShortcuts.SetShortcutHandlers({ + "PlatformCmd-S": save + }); + } + set_save_shortcut(); CloudPebble.Sidebar.SetActivePane(pane, { id: 'resource-' + resource.id, - onRestore: _.partial(restore_pane, pane) + onRestore: function() { + restore_pane(pane); + set_save_shortcut(); + }, + onSuspend: function() { + CloudPebble.GlobalShortcuts.RemoveShortcutHandler("PlatformCmd-S"); + } }); pane.find('#edit-resource-type').val(resource.kind).attr('disabled', 'disabled'); pane.find('#edit-resource-type').change(); - var save = function(e) { + function save(e) { if (e) e.preventDefault(); process_resource_form(form, false, resource.file_name, "/ide/project/" + PROJECT_ID + "/resource/" + resource.id + "/update").then(function(data) { delete project_resources[resource.file_name]; @@ -764,9 +775,6 @@ CloudPebble.Resources = (function() { }).init(); form.submit(save); - CloudPebble.GlobalShortcuts.SetShortcutHandlers({ - save: save - }); restore_pane(pane); }).finally(function() {