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

Commit 8e04541

Browse files
committed
Add guard against changed files
If the file changes between when the lint was triggered and the start of output processing simply tell Linter to not update the messages instead of attempting to mark a document in a different state from when the output was generated.
1 parent c75dde6 commit 8e04541

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default {
2929
lintOnFly: true,
3030
lint: async (textEditor) => {
3131
const filePath = textEditor.getPath();
32+
const fileText = textEditor.getText();
3233
const fileExtension = extname(filePath).substr(1);
3334

3435
if (this.ignoredExtensions.includes(fileExtension)) {
@@ -37,10 +38,14 @@ export default {
3738

3839
const execArgs = ['-wc', '-E utf-8'];
3940
const execOpts = {
40-
stdin: textEditor.getText(),
41+
stdin: fileText,
4142
stream: 'stderr',
4243
};
4344
const output = await helpers.exec(this.executablePath, execArgs, execOpts);
45+
if (textEditor.getText() !== fileText) {
46+
// File contents have changed, just tell Linter not to update messages
47+
return null;
48+
}
4449
const toReturn = [];
4550
let match = regex.exec(output);
4651
while (match !== null) {

0 commit comments

Comments
 (0)