From 537ff68edda2f623da958b1bb73bac038b74f8e8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 19 Apr 2020 07:18:24 -0700 Subject: [PATCH] In Differential, make the "Open in Editor" keystroke work with no selection, or a change or inline selected Summary: Ref T13515. Currently, "Open in Editor" only works with a file-level selection. - If we have a change-level or inline-level selection, open the parent changeset. - If we have no selection, but the banner is showing something, open the fine shown in the banner. Test Plan: With files, inlines, changes, and no selection, pressed "\". Saw files pop open in my external editor. Maniphest Tasks: T13515 Differential Revision: https://secure.phabricator.com/D21148 --- resources/celerity/map.php | 14 ++++---- .../js/application/diff/DiffChangesetList.js | 33 +++++++++++-------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 75328646b4..80341e1c3f 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -12,7 +12,7 @@ return array( 'core.pkg.css' => 'a4a2417c', 'core.pkg.js' => '4355a8d3', 'differential.pkg.css' => '607c84be', - 'differential.pkg.js' => 'ececaeef', + 'differential.pkg.js' => '1a72918e', 'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.js' => 'a98c0bf7', 'maniphest.pkg.css' => '35995d6d', @@ -378,7 +378,7 @@ return array( 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 'rsrc/js/application/diff/DiffChangeset.js' => '5a4e4a3b', - 'rsrc/js/application/diff/DiffChangesetList.js' => 'f813ef26', + 'rsrc/js/application/diff/DiffChangesetList.js' => '139299d7', 'rsrc/js/application/diff/DiffInline.js' => '16e97ebc', 'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17', 'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd', @@ -775,7 +775,7 @@ return array( 'phabricator-darkmessage' => '26cd4b73', 'phabricator-dashboard-css' => '5a205b9d', 'phabricator-diff-changeset' => '5a4e4a3b', - 'phabricator-diff-changeset-list' => 'f813ef26', + 'phabricator-diff-changeset-list' => '139299d7', 'phabricator-diff-inline' => '16e97ebc', 'phabricator-drag-and-drop-file-upload' => '4370900d', 'phabricator-draggable-list' => '0169e425', @@ -1023,6 +1023,10 @@ return array( 'javelin-uri', 'phabricator-keyboard-shortcut', ), + '139299d7' => array( + 'javelin-install', + 'phuix-button-view', + ), '139ef688' => array( 'javelin-behavior', 'javelin-dom', @@ -2166,10 +2170,6 @@ return array( 'javelin-stratcom', 'javelin-dom', ), - 'f813ef26' => array( - 'javelin-install', - 'phuix-button-view', - ), 'f84bcbf4' => array( 'javelin-behavior', 'javelin-stratcom', diff --git a/webroot/rsrc/js/application/diff/DiffChangesetList.js b/webroot/rsrc/js/application/diff/DiffChangesetList.js index 9f5af9a63b..2208c60d18 100644 --- a/webroot/rsrc/js/application/diff/DiffChangesetList.js +++ b/webroot/rsrc/js/application/diff/DiffChangesetList.js @@ -462,23 +462,28 @@ JX.install('DiffChangesetList', { var pht = this.getTranslations(); var cursor = this._cursorItem; + var changeset; if (cursor) { - if (cursor.type == 'file') { - var changeset = cursor.changeset; - var editor_uri = changeset.getEditorURI(); - - if (editor_uri === null) { - this._warnUser(pht('No external editor is configured.')); - return; - } - - JX.$U(editor_uri).go(); - - return; - } + changeset = cursor.changeset; } - this._warnUser(pht('You must select a file to edit.')); + if (!changeset) { + changeset = this._getVisibleChangeset(); + } + + if (!changeset) { + this._warnUser(pht('You must select a file to edit.')); + return; + } + + var editor_uri = changeset.getEditorURI(); + + if (editor_uri === null) { + this._warnUser(pht('No external editor is configured.')); + return; + } + + JX.$U(editor_uri).go(); }, _onkeycollapse: function() {