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

Fix formatting when no project is loaded #44

Merged
merged 1 commit into from
Feb 7, 2023
Merged

Fix formatting when no project is loaded #44

merged 1 commit into from
Feb 7, 2023

Conversation

godric-cz
Copy link
Contributor

When no project is loaded (for example when editing single file by subl --new-window somefile), then plugin fails with stacktrace:

PHP CS Fixer: Formatting view...
PHP CS Fixer: Using config: /home/godric/.php-cs-fixer.php
Traceback (most recent call last):
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1494, in run_
    return self.run(edit)
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 315, in run
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 329, in format
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 264, in format
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 288, in format_contents
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 300, in format_file
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 162, in run
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 184, in create_cmd
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 234, in get_configured_php_cs_fixer_path
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 246, in locate_php_cs_fixer
  File "/home/godric/.config/sublime-text-3/Installed Packages/PHP CS Fixer.sublime-package/SublimePhpCsFixer.py", line 55, in fixer_possible_paths
TypeError: 'NoneType' object is not subscriptable

This handles the situation and tries to load <project>/vendor/bin/php-cs-fixer only when project is not None.

@adael adael merged commit 9d9b3f0 into adael:master Feb 7, 2023
@adael
Copy link
Owner

adael commented Feb 7, 2023

Thanks you for your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants