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

Please save before fixing #972

Closed
adamreisnz opened this issue Jul 26, 2017 · 6 comments
Closed

Please save before fixing #972

adamreisnz opened this issue Jul 26, 2017 · 6 comments

Comments

@adamreisnz
Copy link

adamreisnz commented Jul 26, 2017

Issue Type

Bug

Issue Description

I occasionally see the message "Please save before fixing", without any further explanation.
This happens usually when I do a replace in file in multiple files across a project (with one or more of those files open in Atom).

Why does this message appear? What can be done about it? This didn't use to appear before a few versions back.

Bug Checklist

  • Restart Atom
    Yes, also happens after restart.

  • Verify the eslint CLI gives the proper result, while linter-eslint does not
    Not applicable here.

  • Paste the output of the Linter Eslint: Debug command from the Command Palette below

Atom version: 1.20.0-dev-19b1810
linter-eslint version: 8.2.1
ESLint version: 4.3.0
Hours since last Atom restart: 0
Platform: darwin
Using global ESLint from: /usr/local/lib/node_modules/eslint
Current file's scopes: [
  "source.js",
  "punctuation.terminator.statement.js"
]
linter-eslint configuration: {
  "fixOnSave": true,
  "useGlobalEslint": true,
  "lintHtmlFiles": false,
  "showRuleIdInMessage": true,
  "disableWhenNoEslintConfig": true,
  "eslintrcPath": "",
  "globalNodePath": "",
  "advancedLocalNodeModules": "",
  "eslintRulesDir": "",
  "disableEslintIgnore": false,
  "disableFSCache": false,
  "scopes": [
    "source.js",
    "source.jsx",
    "source.js.jsx",
    "source.babel",
    "source.js-semantic"
  ],
  "rulesToSilenceWhileTyping": [],
  "rulesToDisableWhileFixing": []
}
@Arcanemagus
Copy link
Member

I'm guessing that the method find-and-replace uses to modify a file you don't currently have open is to:

  1. Open an editor to the file
  2. Make the desired change
  3. Save the file
  4. Close the editor

If you have enabled the Fix on Save option, we add an observer for all editors that triggers when they are saved. Before sending a fix job to the worker it checks whether the editor is still valid, and that it hasn't been modified. I'm guessing that between triggering the save and Atom getting around to feeding the event to us, the editor has been closed and thus is no longer valid.

@IanVS do you think we should just silently exit if the editor isn't valid instead of telling the user something went wrong? I'm not sure we could handle this in any other way.

@adamreisnz You can safely ignore the message, it's mainly just there to yell at people that try to fix unsaved files 😉.

@adamreisnz
Copy link
Author

Thanks, I figured it'd be something like that :)

@IanVS
Copy link
Member

IanVS commented Jul 27, 2017

do you think we should just silently exit if the editor isn't valid

I'd be fine with that. Not getting a success message should be enough to indicate that nothing happened. If we wanted to be a bit safer, we could also send a log to the console, just in case someone is confused and checks it.

@IanVS
Copy link
Member

IanVS commented Aug 7, 2017

@adamreisnz do you want to take a crack at a PR?

@adamreisnz
Copy link
Author

@IanVS I would if I had the time, but unfortunately between my contracting work, personal projects and open source projects that I'm already involved in I don't have the time currently to dig into any other packages, sorry!

Arcanemagus added a commit that referenced this issue Aug 9, 2017
When a fix job is triggered but the TextEditor is invalid by the time
the job runs silently return.

Fixes #972.
@Arcanemagus Arcanemagus added the bug label Aug 9, 2017
Arcanemagus added a commit that referenced this issue Aug 9, 2017
When a fix job is triggered but the TextEditor is invalid by the time
the job runs silently return.

Fixes #972.
@Arcanemagus
Copy link
Member

Released in v8.3.0, sorry about the delay!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants