python / cpython

The Python programming language
https://www.python.org
Other
62.39k stars 29.96k forks source link

IDLE grep: always display full search path #80504

Open terryjreedy opened 5 years ago

terryjreedy commented 5 years ago
BPO 36323
Nosy @terryjreedy, @eamanu, @csabella

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = 'https://github.com/terryjreedy' closed_at = None created_at = labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7'] title = 'IDLE: always display full grep path' updated_at = user = 'https://github.com/terryjreedy' ``` bugs.python.org fields: ```python activity = actor = 'terry.reedy' assignee = 'terry.reedy' closed = False closed_date = None closer = None components = ['IDLE'] creation = creator = 'terry.reedy' dependencies = [] files = [] hgrepos = [] issue_num = 36323 keywords = [] message_count = 4.0 messages = ['338115', '338118', '338468', '338525'] nosy_count = 3.0 nosy_names = ['terry.reedy', 'eamanu', 'cheryl.sabella'] pr_nums = [] priority = 'normal' resolution = None stage = 'test needed' status = 'open' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue36323' versions = ['Python 3.7', 'Python 3.8'] ```

terryjreedy commented 5 years ago

The second line of the Find in Files dialog is In files: [____] When this is opened in the startup directory, Shell or an untitled editor, the entry starts as '*.py'. When this is opened in an titled editor file, the initial entry is the full path. A full path is much more useful and should always be given.

terryjreedy commented 5 years ago

To be more exact, if 'Find in Files' is called in an unsaved editor window, including Output windows, the the entry starts as '*.py'. I presume that this is relative to the current working directory, which is initially the startup directory. But this can change in an undocumented way. There is currently no way in a grep output to determine which directory was searched. This is especially annoying when there are no hits and one knows that there should be some.

My initial thought was to prefix '*.py' with the directory of sys.executable. os.getcwd() might be more useful. This would be in GrepDialog.open. This will still be untested after PR12203 for bpo-23205. Most of this method is self-free path manipulation that can be pulled into a module method and separately tested.

PR12203 adds os.curdir ('.') to no-directory patterns. After this issue, that will not be necessary unless a user deletes the explicit directory. I am pausing a PR for this issue until I finish reviewing that one and it is merged.

In the long run, I might like to separate the 'In files' glob path into 'Directory' and file glob pattern. (On Windows at least, glob patterns are not allowed in the directory part of the pattern.)

A related improvement would be listing the base search directory once at the top of output windows and not repeat it on every hit line. This would require revising the GoTo File/Line function.

csabella commented 5 years ago

See also bpo-21960. I'm going to close that one in favor of this issue.

terryjreedy commented 5 years ago

Thanks. I somehow never marked it for IDLE. Using groupby components, I discovered another +-10 and marked them and included in my list.