1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00

Locate File: allow to search './path/to/something.txt'

Summary:
Before this change, if you search a file using Locate File,
this was the only accepted syntax for a full-path:

    path/to/something.txt

After this change, some relative/absolute Unix-like variants
are also accepted:

    ./path/to/something.txt
    /path/to/something.txt

Similar prefixes can be frequent when you quickly copy-paste things
from shell commands like 'grep' or 'find' etc.

Ref T15508

Test Plan:
Visit a lovely repository like Phorge and use Locate File with these:

1. src/applications/maniphest/editor/ManiphestEditEngine.php
2. /src/applications/maniphest/editor/ManiphestEditEngine.php
3. ./src/applications/maniphest/editor/ManiphestEditEngine.php

After this change, also 2. and 3. return the expected file.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15508

Differential Revision: https://we.phorge.it/D25320
This commit is contained in:
Valerio Bozzolan 2023-07-04 17:10:19 +02:00
parent 603cf474ee
commit 4a0d3ba3e1
2 changed files with 12 additions and 8 deletions

View file

@ -387,7 +387,7 @@ return array(
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd',
'rsrc/js/application/differential/behavior-populate.js' => 'b86ef6c2',
'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => '94243d89',
'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => '6c798a10',
'rsrc/js/application/diffusion/ExternalEditorLinkEngine.js' => '48a8641f',
'rsrc/js/application/diffusion/behavior-audit-preview.js' => 'b7b73831',
'rsrc/js/application/diffusion/behavior-commit-branches.js' => '4b671572',
@ -707,7 +707,7 @@ return array(
'javelin-chart-function-label' => '81de1dab',
'javelin-color' => '78f811c9',
'javelin-cookie' => '05d290ef',
'javelin-diffusion-locate-file-source' => '94243d89',
'javelin-diffusion-locate-file-source' => '6c798a10',
'javelin-dom' => 'e4c7622a',
'javelin-dynval' => '202a2e85',
'javelin-event' => 'c03f2fb4',
@ -1555,6 +1555,12 @@ return array(
'phabricator-textareautils',
'phabricator-remarkup-metadata',
),
'6c798a10' => array(
'javelin-install',
'javelin-dom',
'javelin-typeahead-preloaded-source',
'javelin-util',
),
'6cfa0008' => array(
'javelin-dom',
'javelin-dynval',
@ -1762,12 +1768,6 @@ return array(
'phabricator-prefab',
'javelin-json',
),
'94243d89' => array(
'javelin-install',
'javelin-dom',
'javelin-typeahead-preloaded-source',
'javelin-util',
),
'9623adc1' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -99,6 +99,10 @@ JX.install('DiffusionLocateFileSource', {
return [];
}
// Be nice with terminal users that may have "./" or "/" prefixes.
// Otherwise, not a single result is returned.
search = search.replace(/^\.?\//, '');
// We know that the results for "abc" are always a subset of the results
// for "a" and "ab" -- and there's a good chance we already computed
// those result sets. Find the longest cached result which is a prefix