Code Monkey home page Code Monkey logo

atom-autosave-onchange's Introduction

Autosave Onchange

You'll be surprised at how much hitting ctrl+s every ten seconds was annoying when you won't have to do it anymore :). -isthatcentered

Description

This is a plugin for the Atom editor which automatically saves the current file after changes are made.

Features

  • Configurable auto-save delay
  • Easily disable and enable auto-save functionality
  • Autosave automatically disables when the commit screen loads for Git Plus (Git Plus automatically commits on save so using both packages can be annoying). This is configurable within the package settings.

Special Thanks

atom-autosave-onchange's People

Contributors

chexwarrior avatar isthatcentered avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

atom-autosave-onchange's Issues

Add a configurable delay?

First thing I noticed was that if I hesitate for a split second while typing a sentence then the file is autosaved and the trailing space removed. I resume typing but now have typo :(

Uncaught Error: Can't save destroyed buffer

[Enter steps to reproduce:]

  1. Using git-plus while adding a commit message.
  2. When pressing spacebar in the commit window it throws this error.

Atom: 1.14.3 x64
Electron: 1.3.13
OS: Microsoft Windows 7 Enterprise
Thrown From: autosave-onchange package 1.1.0

Stack Trace

Uncaught Error: Can't save destroyed buffer

At C:\Users\Null\AppData\Local\atom\app-1.14.3\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:1055

Error: Can't save destroyed buffer
    at TextBuffer.module.exports.TextBuffer.saveAs (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1055:15)
    at TextBuffer.module.exports.TextBuffer.save (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1049:19)
    at TextEditor.module.exports.TextEditor.save (/app.asar/src/text-editor.js:891:26)
    at Package.trigger (/packages/autosave-onchange/lib/package.js:27:16)
    at Package.onDidChangeCursorPosition (/packages/autosave-onchange/lib/package.js:11:18)
    at /packages/autosave-onchange/lib/autosave-delay.js:47:29
    at invokeFunc (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:160:19)
    at trailingEdge (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:207:14)
    at timerExpired (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:195:14)

Commands

     -2:33.3.0 editor:consolidate-selections (input.hidden-input)
     -2:33.3.0 core:cancel (input.hidden-input)
     -2:30.1.0 command-palette:toggle (input.hidden-input)
 17x -2:23.8.0 core:backspace (input.hidden-input)
     -2:17.9.0 editor:consolidate-selections (input.hidden-input)
     -2:17.9.0 core:cancel (input.hidden-input)
 13x -2:15.9.0 git-plus:add (input.hidden-input)
     -2:15.6.0 command-palette:toggle (input.hidden-input)
     -2:14.1.0 editor:consolidate-selections (input.hidden-input)
     -2:14.1.0 core:cancel (input.hidden-input)
     -2:05.5.0 git-plus:add (input.hidden-input)
     -2:00.6.0 application:add-project-folder (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
     -2:00.6.0 tree-view:copy-full-path (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
  2x -1:52.3.0 git-plus:commit (input.hidden-input)
     -0:51.1.0 command-palette:toggle (input.hidden-input)
     -0:47.4.0 git-plus:commit-amend (input.hidden-input)

Non-Core Packages

advanced-open-file 0.16.5 
atom-beautify 0.29.17 
atom-ternjs 0.17.2 
autoreload-package-service 0.0.4 
autosave-onchange 1.1.0 
duplicate-line-or-selection 0.9.0 
emmet 2.4.3 
emmet-snippets-compatibility 1.0.6 
git-clone 0.2.0 
git-control 0.8.2 
git-plus 7.3.0 
language-javascript-jsx 0.3.7 
minimap 4.26.8 
platformio-ide-terminal 2.2.3 

Failed to load the autosave-onchange package

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.30.0 x64
Electron: 2.0.5
OS: Microsoft Windows 10 Enterprise
Thrown From: autosave-onchange package 1.5.1

Stack Trace

Failed to load the autosave-onchange package

At Cannot find module 'lodash.debounce'

Error: Cannot find module 'lodash.debounce'
    at Module._resolveFilename (module.js:543:15)
    at Module._resolveFilename (~/AppData/Local/atom/app-1.30.0/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.get_Module._resolveFilename (<embedded>:12380:58)
    at Module.require (/app.asar/static/index.js:40:43)
    at require (<embedded>:11724:33)
    at /packages/atom-autosave-onchange-1.5.1/lib/autosave-onchange.js:15:23)
    at /packages/atom-autosave-onchange-1.5.1/lib/autosave-onchange.js:108:3)
    at Module.get_Module._compile (<embedded>:11764:36)
    at Object.value [as .js] (<embedded>:12016:29)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (/app.asar/static/index.js:47:45)
    at require (internal/module.js:11:18)
    at customRequire (<embedded>:96:26)
    at Package.requireMainModule (<embedded>:75880:33)
    at measure (<embedded>:75241:22)
    at Package.measure (<embedded>:75186:25)
    at Package.load (<embedded>:75227:16)
    at PackageManager.loadAvailablePackage (<embedded>:26124:16)
    at config.transact (<embedded>:26037:20)
    at Config.transact (<embedded>:22707:20)
    at PackageManager.loadPackages (<embedded>:26035:23)
    at loadStatePromise.loadState.then (<embedded>:1080:27)
    at <anonymous>:null:null

Commands

Non-Core Packages

autosave-onchange 1.5.1 

Uncaught Error: EPERM: operation not permitted, mkdir 'C:/xampp\htdocs\scheduler\resources\views\...

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.18.0 x64
Electron: 1.3.15
OS: Microsoft Windows 10 Home Single Language
Thrown From: autosave-onchange package 1.5.1

Stack Trace

Uncaught Error: EPERM: operation not permitted, mkdir 'C:\xampp\htdocs\scheduler\resources\views\pages\users\osa-user\organization'

At C:\atom\app-1.18.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:1136

Error: EPERM: operation not permitted, mkdir 'C:\xampp\htdocs\scheduler\resources\views\pages\users\osa-user\organization'
    at Error (native)
    at fs.mkdirSync (fs.js:922:18)
    at Object.fs.mkdirSync (ELECTRON_ASAR.js:665:16)
    at Function.sync (C:/atom/app-1.18.0/resources/app/node_modules/mkdirp/index.js:81:19)
    at Proxy.writeFileSync (C:/atom/app-1.18.0/resources/app/node_modules/fs-plus/lib/fs-plus.js:297:20)
    at File.module.exports.File.writeFileSync (C:/atom/app-1.18.0/resources/app/node_modules/pathwatcher/lib/file.js:289:25)
    at File.module.exports.File.writeFileWithPrivilegeEscalationSync (C:/atom/app-1.18.0/resources/app/node_modules/pathwatcher/lib/file.js:467:27)
    at File.module.exports.File.writeSync (C:/atom/app-1.18.0/resources/app/node_modules/pathwatcher/lib/file.js:384:18)
    at TextBuffer.module.exports.TextBuffer.saveAs (C:/atom/app-1.18.0/resources/app/node_modules/text-buffer/lib/text-buffer.js:1127:25)
    at TextBuffer.module.exports.TextBuffer.save (C:/atom/app-1.18.0/resources/app/node_modules/text-buffer/lib/text-buffer.js:1108:25)
    at TextEditor.module.exports.TextEditor.save (C:/atom/app-1.18.0/resources/app/src/text-editor.js:925:32)
    at Package.trigger (/packages/autosave-onchange/lib/package.js:23:28)
    at Package.onDidChangeCursorPosition (/packages/autosave-onchange/lib/package.js:9:12)
    at /packages/autosave-onchange/lib/autosave-onchange.js:82:18
    at invokeFunc (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:160:19)
    at trailingEdge (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:207:14)
    at timerExpired (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:195:14)

Commands

     -7:00.6.0 core:select-all (input.hidden-input)
     -6:59.6.0 core:cut (input.hidden-input)
     -6:55.6.0 core:select-all (input.hidden-input)
  2x -6:54.3.0 core:paste (input.hidden-input)
     -5:50.6.0 find-and-replace:show (input.hidden-input)
  4x -5:46.9.0 core:confirm (input.hidden-input)
     -5:41.3.0 core:move-right (input.hidden-input)
     -5:34.2.0 core:move-left (input.hidden-input)
     -5:29.8.0 find-and-replace:show (input.hidden-input)
  6x -5:27.9.0 core:confirm (input.hidden-input)
     -5:17.7.0 core:backspace (input.hidden-input)
  3x -5:15.9.0 core:move-right (input.hidden-input)
     -5:10.5.0 core:backspace (input.hidden-input)
     -5:10 core:move-right (input.hidden-input)
 41x -5:01.8.0 core:backspace (input.hidden-input)
     -0:00.2.0 core:save (input.hidden-input)

Non-Core Packages

alignment 1.1.5 
atom-bootstrap3 1.2.12 
atom-terminal 0.8.0 
autosave-onchange 1.5.1 
base-16-ocean-dark-ui-theme 1.7.2 
browser-plus 0.0.98 
browser-plus-block 0.0.4 
browser-plus-open-new-window 0.0.1 
chameleon-ui 1.0.0 
chester-atom-2-syntax 0.1.0 
chester-syntax 0.4.0 
docblockr 0.10.5 
editor-background 1.2.38 
emmet 2.4.3 
facebook-syntax-theme 1.2.1 
fizzy-syntax-theme 0.9.0 
focus-ui 2.6.0 
fox-syntax-theme 1.2.0 
gruvbox-plus-syntax 1.3.1 
hecs-dark-theme-syntax 0.1.1 
icon-fonts 2.16.2 
improved-chester-atom-syntax 0.3.0 
jonikorpi-atom-theme-ui 4.4.1 
lunar-particle-syntax 0.3.8 
lunar-particle-ui 0.3.13 
lxso-theme 0.0.1 
one-dark-vivid-syntax 1.8.0 
seti-icons 1.5.4 
tasks 2.6.6 
tree-view-background 0.4.3 
vanian-ui 1.5.4 

Changes required due to TextBuffer.save becoming async in Atom 1.19

Hi! Thanks for maintaining the autosave-onchange package!

In Atom v1.19, we will release a major change to Atom's core text buffer data structure. As part of this change, we have made TextBuffer.save asynchronous; rather than blocking until the save is complete, it now immediately returns a Promise that resolves when the save is complete. Because of this, a few other Atom APIs that use save have similarly become async:

  • Pane.close
  • TextBuffer.save
  • TextEditor.save
  • Pane.saveItem
  • Pane.saveItemAs
  • Pane.saveActiveItem
  • Pane.saveActiveItemAs
  • Pane.saveItems
  • Workspace.saveActivePaneItem
  • Workspace.saveActivePaneItemAs

Effects on this package

We think this package could be impacted by this upgrade because it calls the changed methods in the following places:

  • TextEditor.save

We found these calls using a regex search, so this list might be incomplete, and it might contain some false positives.

What to do about the change

It should be pretty easy to adjust your package code and/or tests to work with the new async behavior, and to simultaneously keep it working with older versions of Atom. Here are some examples of pull requests we opened on our bundled packages to cope with the change:

Please let me know if you have any questions. I'd be happy to help!

Auto save DOES NOT work

When i type something new into a file, autosave-onchange does not save it automatically even though i have it installed correctly.

Uncaught Error: EACCES: permission denied, open '~/Documents/djs559.github.io/WEEK2_CSSexercises/...

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.15.0 x64
Electron: 1.3.13
OS: Linux Mint
Thrown From: autosave-onchange package 1.1.0

Stack Trace

Uncaught Error: EACCES: permission denied, open '/home/themorningstar/Documents/djs559.github.io/WEEK2_CSSexercises/index.html'

At /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1076

Error: EACCES: permission denied, open '/home/themorningstar/Documents/djs559.github.io/WEEK2_CSSexercises/index.html'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:168:20)
    at Object.fs.writeFileSync (fs.js:1343:33)
    at Object.writeFileSync (/app.asar/node_modules/fs-plus/lib/fs-plus.js:281:17)
    at File.module.exports.File.writeFileSync (/app.asar/node_modules/text-buffer/node_modules/pathwatcher/lib/file.js:285:19)
    at File.module.exports.File.writeFileWithPrivilegeEscalationSync (/app.asar/node_modules/text-buffer/node_modules/pathwatcher/lib/file.js:463:21)
    at File.module.exports.File.writeSync (/app.asar/node_modules/text-buffer/node_modules/pathwatcher/lib/file.js:380:12)
    at TextBuffer.module.exports.TextBuffer.saveAs (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1067:19)
    at TextBuffer.module.exports.TextBuffer.save (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1048:19)
    at TextEditor.module.exports.TextEditor.save (/app.asar/src/text-editor.js:915:26)
    at Package.trigger (/packages/autosave-onchange/lib/package.js:27:16)
    at Package.onDidChangeCursorPosition (/packages/autosave-onchange/lib/package.js:11:18)
    at /packages/autosave-onchange/lib/autosave-delay.js:47:29
    at invokeFunc (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:160:19)
    at trailingEdge (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:207:14)
    at timerExpired (/packages/autosave-onchange/node_modules/lodash.debounce/index.js:195:14)

Commands

     -3:51.2.0 command-palette:toggle (input.hidden-input)
     -3:41.9.0 core:confirm (input.hidden-input)
     -3:41.9.0 tree-view:show (input.hidden-input)
     -3:33.4.0 tree-view:toggle-focus (input.hidden-input)
  2x -3:26.4.0 application:open-file (input.hidden-input)
     -1:43.6.0 snippets:next-tab-stop (input.hidden-input)
     -1:43.6.0 snippets:expand (input.hidden-input)
     -1:43.5.0 editor:indent (input.hidden-input)
  3x -1:41.7.0 core:backspace (input.hidden-input)
     -1:39.8.0 snippets:next-tab-stop (input.hidden-input)
     -1:39.8.0 snippets:expand (input.hidden-input)
     -1:39.7.0 editor:indent (input.hidden-input)
  4x -1:39.1.0 core:backspace (input.hidden-input)
  2x -1:36.7.0 core:save (input.hidden-input)
     -0:30 core:backspace (input.hidden-input)
     -0:27.9.0 emmet:expand-abbreviation-with-tab (input.hidden-input)

Non-Core Packages

atom-html-preview 0.1.22 
autosave-onchange 1.1.0 
emmet 2.4.3 

Autosave-onchange and whitespace plugin while editing at the end of file.

Description

When using autosave-onchange and whitespace plugin with "Ensure Single Trailing Whitespace", one's ability to edit the file at it's end is reduced, since autosave-onchange saves the file every 500ms, and whitespace automatically removes the whitespace at the end.

I love to create a few new lines to start a new paragraph before thinking of what exactly should I be writing right now, and then autosave-onchange kicks in and saves the file. Whitespace plugin, triggered by autosave-onchange, will remove all of the newly created whitespace (although it is useful in this case). It is unreasonably annoying - requires me to always add a non-empty line, so that this behaviour wouldn't distract me.

I can also see how this functionality may require more work than the amount of work it takes to fix it in the first place. So in such scenario it may be nice to hear the opinions of the official maintainers of the plugin.

Also not exactly sure if that's a whitespace or an autosave-onchange issue.

Steps to Reproduce

  1. Set up whitespace plugin with "Ensure Single Trailing Whitespace"
  2. Set up autosave-onchange plugin (no additional settings needed).
  3. Create a new file and save it somewhere on the disk (so that autosave-onchange would start working).
  4. Press enter a few times
  5. Wait a few moments.
  6. autosave-onchange will save the file and whitespace plugin will remove the trailing spaces you had just created, moving the caret to the beginning of the file.

Expected behavior:
I expect the whitespace to be automatically removed when I am not directly editing the file (e.g. when autosave-onchange runs after I had removed the caret from the end of file).

Actual behavior:
Whitespace plugin runs immediately and removes the useful newlines.

Reproduces how often:

100%.

Versions

Atom    : 1.31.2
Electron: 2.0.7
Chrome  : 61.0.3163.100
Node    : 8.9.3

Failed to activate the autosave-onchange package

[Enter steps to reproduce:]

  1. Upgraded to Atom 1.16 (Beta) on mac
  2. Started Atom

Atom: 1.16.0-beta0 x64
Electron: 1.3.13
OS: Mac OS X 10.12.3
Thrown From: autosave-onchange package 1.1.0

Stack Trace

Failed to activate the autosave-onchange package

At /Users/null/.atom/packages/autosave-onchange/lib/autosave-delay.js: package is a reserved word in strict mode (22:6)

SyntaxError: /Users/null/.atom/packages/autosave-onchange/lib/autosave-delay.js: package is a reserved word in strict mode (22:6)
  20 | import debounce from 'lodash.debounce';
  21 | 
> 22 | const package = new Package();
     |       ^
  23 | 
  24 | export default {
  25 | 
    at /app.asar/node_modules/babylon/lib/index.js:4373:13)
    at /app.asar/node_modules/babylon/lib/index.js:4270:10)
    at /app.asar/node_modules/babylon/lib/index.js:3084:12)
    at Parser.checkLVal (/app.asar/node_modules/babylon/lib/index.js:5928:22)
    at /app.asar/node_modules/babylon/lib/index.js:2311:8)
    at Parser.parseVarHead (/app.asar/node_modules/babylon/lib/index.js:6153:13)
    at /app.asar/node_modules/babylon/lib/index.js:2293:10)
    at /app.asar/node_modules/babylon/lib/index.js:2124:8)
    at /app.asar/node_modules/babylon/lib/index.js:1816:19)
    at Parser.parseStatement (/app.asar/node_modules/babylon/lib/index.js:5712:22)
    at /app.asar/node_modules/babylon/lib/index.js:2223:21)
    at /app.asar/node_modules/babylon/lib/index.js:1733:8)
    at Parser.parse (/app.asar/node_modules/babylon/lib/index.js:1628:17)
    at parse (/app.asar/node_modules/babylon/lib/index.js:7083:37)
    at File.parse (/app.asar/node_modules/babel-core/lib/transformation/file/index.js:527:15)
    at File.parseCode (/app.asar/node_modules/babel-core/lib/transformation/file/index.js:612:20)
    at /app.asar/node_modules/babel-core/lib/transformation/pipeline.js:49:12
    at File.wrap (/app.asar/node_modules/babel-core/lib/transformation/file/index.js:574:16)
    at Pipeline.transform (/app.asar/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
    at Object.exports.compile (/app.asar/src/babel.js:72:16)
    at Object.compile (/app.asar/src/package-transpilation-registry.js:54:27)
    at compileFileAtPath (/app.asar/src/compile-cache.js:91:31)
    at /app.asar/src/compile-cache.js:215:18)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (/app.asar/src/native-compile-cache.js:50:27)
    at Package.module.exports.Package.requireMainModule (/app.asar/src/package.js:796:27)
    at Package.module.exports.Package.activateNow (/app.asar/src/package.js:207:16)

Commands

Non-Core Packages

advanced-open-file 0.16.5 
atom-beautify 0.29.17 
atom-live-server 2.1.2 
atom-ternjs 0.18.1 
autosave-onchange 1.1.0 
duplicate-line-or-selection 0.9.0 
emmet 2.4.3 
emmet-snippets-compatibility 1.0.6 
git-clone 0.2.0 
git-control 0.8.2 
git-plus 7.3.3 
language-babel 2.55.6 
language-javascript-jsx 0.3.7 
minimap 4.26.8 
platformio-ide-terminal 2.4.0 
sync-settings 0.8.1 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.