Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit b0fafa3

Browse files
committed
If using .clang-complete disable for modified files
If there is a .clang-complete file it sends a flag to clang setting the working directory to that of the .clang-complete file, breaking relative includes for a file sent in over stdin. If a .clang-complete is in use disable linting modified files.
1 parent 7656da0 commit b0fafa3

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/main.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,12 @@ export default {
214214
args.push(`-I${path}`),
215215
);
216216

217+
let usingClangComplete = false;
217218
try {
218219
const flags = clangFlags.getClangFlags(filePath);
219-
if (flags) {
220+
if (flags.length > 0) {
220221
args.push(...flags);
222+
usingClangComplete = true;
221223
}
222224
} catch (error) {
223225
if (atom.inDevMode()) {
@@ -226,15 +228,25 @@ export default {
226228
}
227229
}
228230

229-
args.push('-');
231+
if (editor.isModified() && usingClangComplete) {
232+
// If the user has a .clang-complete file we can't lint current
233+
// TextEditor contents, return null so nothing gets modified
234+
return null;
235+
}
230236

231237
const execOpts = {
232-
stdin: fileText,
233238
stream: 'stderr',
234239
allowEmptyStderr: true,
235-
cwd: fileDir,
236240
};
237241

242+
if (usingClangComplete) {
243+
args.push(filePath);
244+
} else {
245+
args.push('-');
246+
execOpts.stdin = fileText;
247+
execOpts.cwd = fileDir;
248+
}
249+
238250
const output = await helpers.exec(this.executablePath, args, execOpts);
239251

240252
if (editor.getText() !== fileText) {

0 commit comments

Comments
 (0)