Page MenuHomePhorge

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

Authored by valerio.bozzolan on Jul 1 2023, 00:49.
Tags
None
Referenced Files
F2982567: D25320.1739963366.diff
Tue, Feb 18, 11:09
F2982566: D25320.1739963364.diff
Tue, Feb 18, 11:09
F2982565: D25320.1739963363.diff
Tue, Feb 18, 11:09
F2982526: D25320.1739962507.diff
Tue, Feb 18, 10:55
F2982478: D25320.1739960396.diff
Tue, Feb 18, 10:19
F2978898: D25320.1739719544.diff
Sat, Feb 15, 15:25
F2963615: D25320.1739215716.diff
Sun, Feb 9, 19:28
F2945393: D25320.1738314074.diff
Thu, Jan 30, 09:01

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
Branch
arcpatch-D25320
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 619
Build 619: arc lint + arc unit

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