Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add switcher integration to projects #20895

Merged
merged 24 commits into from
Jul 3, 2023

Conversation

AngelaRemolina
Copy link
Contributor

@AngelaRemolina AngelaRemolina commented May 4, 2023

Description of Changes

  1. If there is an active project opened, the switcher now loads the files of that project searching them with fzf.
  2. Project files can be loaded into the editor from swicher selection
  3. When the user types the search text the name of a project in the switcher dialog it is filtered by fzf
  4. Added a unit test to assert number of files loaded in the switcher with the editor+projects files.
  5. Wait for the user to stop typing (300ms) to execute fzf function (with QTimer) instead of doing it everytime text changes.

Future work:

  • Migrate the fzf subprocess function to ProcessWorker
  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)

switcher_fzf

Issue(s) Resolved

Fixes #3860

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct:

@angelasofiaremolinagutierrez

@AngelaRemolina AngelaRemolina marked this pull request as ready for review May 6, 2023 22:36
@AngelaRemolina AngelaRemolina changed the title [WIP] Switcher integration to projects Switcher integration to projects May 6, 2023
@ccordoba12 ccordoba12 changed the title Switcher integration to projects PR: Add switcher integration to projects May 9, 2023
Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @angelasofiaremolinagutierrez for all your work here! Left a couple of suggestions for some docstrings and some comments about the signal to open the switcher selection in the Editor. Also, left some comments/ideas regarding the usage of the switcher reference from the main widget. However, regarding that last part (usage of the switcher reference from the main widget), what do you think @ccordoba12 ?

I'm missing running this changes locally but seems like everything should be working 👍

If you have any comment or question regarding the comments in the review let me know!

spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
AngelaRemolina and others added 4 commits May 10, 2023 10:17
- Add parameter with switcher items list.
- Document fzf function
Co-authored-by: Daniel Althviz Moré <[email protected]>
Copy link
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked locally the PR and seems like some logic to handle the case when fzf is not installed needs to be added? I tried without installing fzf first and I got:

Traceback (most recent call last):
  File "e:\acer\documentos\spyder\spyder otros\angela\spyder\spyder\plugins\projects\plugin.py", line 447, in handle_switcher_modes
    self.get_widget().handle_switcher_modes("")
  File "e:\acer\documentos\spyder\spyder otros\angela\spyder\spyder\plugins\projects\widgets\main_widget.py", line 617, in handle_switcher_modes
    paths = self._execute_fzf_subprocess()
  File "e:\acer\documentos\spyder\spyder otros\angela\spyder\spyder\plugins\projects\widgets\main_widget.py", line 732, in _execute_fzf_subprocess
    out = subprocess.check_output(cmd_list, cwd=project_path,
  File "C:\Users\dalth\anaconda3\envs\spyder-dev\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\dalth\anaconda3\envs\spyder-dev\lib\subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\dalth\anaconda3\envs\spyder-dev\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\dalth\anaconda3\envs\spyder-dev\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado

Left new suggestions that maybe could help with the tests failing and the handling of the case when fzf is not installed.

Testing locally, after installing fzf and applying the suggested changes, things are looking good (a little bit of lag but that is expected 👍):

fzf

spyder/plugins/switcher/widgets/switcher.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @angelasofiaremolinagutierrez for your work on this!

spyder/plugins/editor/utils/switcher_manager.py Outdated Show resolved Hide resolved
spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/projects/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/plugin.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/plugin.py Outdated Show resolved Hide resolved
AngelaRemolina and others added 3 commits May 13, 2023 21:06
Co-authored-by: Carlos Cordoba <[email protected]>
Co-authored-by: Daniel Althviz Moré <[email protected]>
- Delete unused functions
- Delete debug prints
- Add docstring to functions in widget
- Move methods to private API
@AngelaRemolina AngelaRemolina deleted the projects-integration branch May 14, 2023 06:05
@AngelaRemolina AngelaRemolina restored the projects-integration branch May 14, 2023 06:05
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last stylistic suggestions @angelasofiaremolinagutierrez, then this should be ready on my side.

spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/projects/widgets/main_widget.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Outdated Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Show resolved Hide resolved
spyder/plugins/switcher/widgets/switcher.py Show resolved Hide resolved
@dalthviz dalthviz modified the milestones: v6.0alpha2, v6.0alpha1 May 19, 2023
@dalthviz dalthviz requested a review from ccordoba12 May 19, 2023 22:01
@ccordoba12 ccordoba12 modified the milestones: v6.0alpha1, v6.0alpha2 Jun 8, 2023
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelasofiaremolinagutierrez, thanks for your hard work to implement this feature!! It's a great improvement!

@ccordoba12 ccordoba12 merged commit 1112396 into spyder-ide:master Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File Switcher should search all project files and not only the open ones
3 participants