Format On Save with Xcode behaviors.
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reproducing the Xcode behavior from the issue's Command+S script, including the clang-format -i and touch commands on a .cpp file. Investigate whether the plugin can invoke formatting within Xcode rather than modifying the file externally. Done would mean formatting on save without showing the external-modification dialog and while retaining the newer disk version.
Written by the indexing model from the issue text.
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...
- Dominant language
- Objective-C++
- Stars
- 807
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/XcodeClangFormat
-
Difficulty 3/5 1-2 days Newbie friendliness 20/100
mapbox/XcodeClangFormat#61 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
mapbox/XcodeClangFormat#60 ·
-
OC怎么自定义代码规范规则? Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
mapbox/XcodeClangFormat#58 · 1 comment ·
-
Not work on Xcode 12 Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
mapbox/XcodeClangFormat#53 · 34 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mapbox/XcodeClangFormat#50 · 4 comments ·
All issues in mapbox/XcodeClangFormat
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ScoopInstaller/Nonportable#639 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ScoopInstaller/Extras#18800 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
uqbar-project/website-wollok-ts#84 · 2 comments ·
-
on hold T: core-bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100