Skip to content

Commit a199239

Browse files
committed
Select the correct language when formatting the code rather than when loading the style
1 parent 97be038 commit a199239

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

clang-format/ClangFormatCommand.mm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ - (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation*)invocatio
119119
style = @"llvm";
120120
}
121121

122-
clang::format::FormatStyle format = clang::format::getLLVMStyle();
123-
format.Language = language;
124-
clang::format::getPredefinedStyle("LLVM", format.Language, &format);
122+
clang::format::FormatStyle format = clang::format::getNoStyle();
125123
if ([style isEqualToString:@"custom"]) {
126124
NSData* config = [self getCustomStyle];
127125
if (!config) {
@@ -194,7 +192,7 @@ - (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation*)invocatio
194192
// Calculated replacements and apply them to the input buffer.
195193
const llvm::StringRef filename("<stdin>");
196194
clang::format::FormattingAttemptStatus status;
197-
auto replaces = clang::format::reformat(format, code, ranges, filename, &status);
195+
auto replaces = clang::format::reformat(format.GetLanguageStyle(language).getValueOr(format), code, ranges, filename, &status);
198196

199197
if (!status.FormatComplete) {
200198
// We could not apply the calculated replacements.

0 commit comments

Comments
 (0)