mapbox / mapbox/XcodeClangFormat
Format On Save with Xcode behaviors.
Personne n'a encore pris cette issue.
- Langage dominant
- Objective-C++
- Étoiles
- 807
- Forks
- 102
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi, in order to allow "Format on Save" I avoid using extensions, but rather set new Xcode behavior hat run the following script upon "Command+S" (which replace the original file save):
My script extract the current file name presented by xcode, and perform clang-format on this file (see below), and it works just fine.
However, when the file is modified, I sometimes get the following message from xcode.
the file for the document at “/Users/me/file.cpp” has been modified by another application. There are also unsaved changes in Xcode. Do you want to keep the Xcode version or revert to the version on disk?
This happens because the file changed outside xcode ... and xcode probably cache the currently file being edited, so I'd like to avoid this message box and always take the newer file version from disk (select the "Revert" option instead of the other option of "Keep Xcode Version") . is it possible to avoid this message box ?
Thanks
#!/bin/sh
CDP=$(osascript -e 'tell application "Xcode"
activate
set current_document to last source document
set current_document_path to path of current_document
end tell ' )
if [[ $CDP == *.cpp ]]
then
/usr/local/bin/clang-format -i ${CDP}
touch ${CDP}
fi
P.S I'm aware this option doesn't related directly to the plugin, but if the plugin can somehow run clang-format from within the xcode, it may solve my problem and avoid this messagebox...
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire le comportement de Xcode à partir du script Command+S de l’issue, notamment les commandes clang-format -i et touch sur un fichier .cpp. Vérifiez si le plugin peut lancer le formatage dans Xcode plutôt que de modifier le fichier à l’extérieur. Le travail sera considéré comme terminé lorsque le formatage s’effectuera à l’enregistrement sans afficher la boîte de dialogue de modification externe, tout en conservant la version plus récente sur le disque.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- cpp, shell
- Domaine
- tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100