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 casing on case-insensitive filesystems #67

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

adrum
Copy link
Contributor

@adrum adrum commented Oct 17, 2024

I noticed an issue where vscode seems to be passing a cached filename on case-insensitive file systems on file events. This PR pulls the latest filename from the system by grabbing the current casing before passing off the file path in PintEditService.formatFile function.

Steps to reproduce:

  1. Enable autoformatting on file save in .vscode/settings.json
{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },
  "laravel-pint.enable": true,
  "laravel-pint.configPath": "pint.json",
  "laravel-pint.executablePath": "vendor/bin/pint",
  "[php]": {
    "editor.defaultFormatter": "open-southeners.laravel-pint"
  }
}

  1. Setup a pint.json config file like so:
{
  "preset": "laravel",
  "rules": {
    "psr_autoloading": true
  }
}
  1. In VSCode, Create test file at app/Actions/wrongCasing.php and save it with autoformatting:

namespace App\Actions;

class wrongCasing {}
  1. Rename the file to the proper casing in vscode app/Actions/wrongCasing.php > app/Actions/wrongCasing2.php > app/Actions/WrongCasing.php
  2. Save the file to trigger formatting.

The file itself still has a class name of wrongCasing instead of WrongCasing derived from the filename.

@adrum adrum changed the title fix casing on case insensitive disks Fix casing on case-insensitive filesystems Oct 18, 2024
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.

1 participant