Page MenuHomePhorge

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

Authored by valerio.bozzolan on Jul 1 2023, 00:49.

Details

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.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

avivey added inline comments.
webroot/rsrc/js/application/diffusion/DiffusionLocateFileSource.js
104

try this - it's how we often write regexps that contain /.

webroot/rsrc/js/application/diffusion/DiffusionLocateFileSource.js
104

Unfortunately, in the proposed way it does not receive a RegExp object, so it does not work as expected.

"./teest/".replace('@^\.?\/@', '') // it returns ./teest/
"@^\.?\/@".replace('@^\.?\/@', '') // it returns an empty string

Also it seems to me that using the RegExp constructor directly also does not offer any native way to use a different delimiter.

Nice to see that even in 2023 JavaScript is terrible.

avivey added inline comments.
webroot/rsrc/js/application/diffusion/DiffusionLocateFileSource.js
104

Oh, it's javascript. Sure.

This revision is now accepted and ready to land.Jul 3 2023, 08:03