mapbox / mapbox/XcodeClangFormat
Format On Save with Xcode behaviors.
還沒有人認領這個 Issue。
- 主要語言
- Objective-C++
- 星號
- 807
- 分支
- 102
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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...
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先根據 issue 中的 Command+S script 重現 Xcode 的行為,包括對 .cpp 檔案執行 clang-format -i 和 touch 指令。調查 plugin 是否能在 Xcode 內呼叫格式化,而不是從外部修改檔案。完成的標準是在儲存時進行格式化,不顯示外部修改對話框,同時保留磁碟上較新的版本。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cpp, shell
- 領域
- tooling
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100