mapbox / mapbox/XcodeClangFormat
Format On Save with Xcode behaviors.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Objective-C++
- Stelle
- 807
- Fork
- 102
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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...
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il comportamento di Xcode dallo script Command+S dell’issue, inclusi i comandi clang-format -i e touch su un file .cpp. Verifica se il plugin può richiamare la formattazione all’interno di Xcode invece di modificare il file esternamente. Il lavoro sarà considerato completato quando la formattazione avverrà al salvataggio senza mostrare la finestra di dialogo relativa alla modifica esterna e mantenendo la versione più recente su disco.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, shell
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100