PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

Search and replace goes into all modules in site-packages

Open therealzoomgod opened this issue 2 years ago • 3 comments

Visual Studio 2022

When using search and replace in a project with a python virtual environment it goes into the installed modules.

Steps to Reproduce

  1. Create a virtual environment
  2. Install some modules
  3. Make a folder in site-packages for your own package you are working on.
  4. Use search and replace and it will go into every package under site-packages (using replace all is then a disaster)

Expected behavior I expect search and replace to work only on source code that is actually part of my project

disclaimer I don't recall having this issue in 2017 or 2019 but not sure I ever made my own module in site-packages in a virtual environment as part of my project.

Thanks

therealzoomgod avatar Aug 19 '22 14:08 therealzoomgod

Hi there, the File types textbox can exclude files. Any path or file type prefixed with the “!” character will be excluded from the search. For instance, you can add !*\site_package* to the file types list to exclude any files in a site_package folder. Could you give it a try and let us know if that works? Thanks!

StellaHuang95 avatar Aug 22 '22 17:08 StellaHuang95

This project is a python package so to test while coding it I need it in the site-packages of the virtual environment. Using a filter means I would have to exclude every other package in installed. If I filter site-packages it would ignore my code then.

Is there some other setting so it only searches files that are actually part of your project ? This should be doable since all files part of the project are listed in the VS project file.

Thanks

therealzoomgod avatar Sep 01 '22 20:09 therealzoomgod

Hi @therealzoomgod, unfortunately, I don’t think we have that capability. That would be a new feature. But thanks for bringing this up! 😊 The walkaround for now is probably do the search and replace twice, one in the folder you made in the site-package, and do another search to exclude the site package folder.

StellaHuang95 avatar Sep 14 '22 17:09 StellaHuang95