[Enter steps to reproduce below:]
Atom Version: 1.7.3
System: Mac OS X 10.11.4
Thrown From: atom-beautify package, v0.29.7
Uncaught TypeError: Cannot read property 'setScrollTop' of null
At /Applications/Atom.app/Contents/Resources/app.asar/src/text-editor-element.js:372
TypeError: Cannot read property 'setScrollTop' of null
at atom-text-editor.TextEditorElement.setScrollTop (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor-element.js:372:28)
at setScrollTop (/Users/musk/.atom/packages/atom-beautify/src/beautify.coffee:35:8)
at /Users/musk/.atom/packages/atom-beautify/src/beautify.coffee:131:13
-7:33.2.0 editor:newline (atom-text-editor.editor.is-focused)
-7:23.3.0 core:move-right (atom-text-editor.editor.is-focused)
-7:19.5.0 core:delete (atom-text-editor.editor.is-focused)
-7:19.5.0 core:move-down (atom-text-editor.editor.is-focused)
-7:18 editor:move-to-end-of-screen-line (atom-text-editor.editor.is-focused)
-7:16.5.0 editor:newline (atom-text-editor.editor.is-focused)
2x -7:14.4.0 core:save (atom-text-editor.editor.is-focused)
-0:01.9.0 core:close (atom-text-editor.editor.is-focused)
{
"core": {
"audioBeep": false,
"disabledPackages": [
"wrap-guide"
]
},
"atom-beautify": {
"apex": {},
"arduino": {},
"c": {},
"cfml": {},
"coffeescript": {},
"cpp": {},
"cs": {},
"css": {
"beautify_on_save": true,
"convert_quotes": "single"
},
"d": {},
"ejs": {},
"erb": {},
"fortran": {},
"general": {
"_analyticsUserId": "ced3a7e6-8d18-4cca-b68c-c7e9ee5fcac8"
},
"gherkin": {},
"handlebars": {},
"html": {},
"jade": {},
"java": {},
"js": {
"beautify_on_save": true
},
"json": {
"beautify_on_save": true
},
"jsx": {},
"latex": {},
"less": {
"beautify_on_save": true
},
"marko": {},
"mustache": {},
"objectivec": {},
"pawn": {},
"perl": {},
"php": {},
"python": {},
"riot": {},
"ruby": {},
"rust": {},
"sass": {
"beautify_on_save": true
},
"scss": {
"beautify_on_save": true
},
"spacebars": {},
"sql": {},
"svg": {},
"swig": {},
"tss": {},
"twig": {},
"typescript": {},
"vala": {},
"visualforce": {},
"xml": {},
"xtemplate": {}
}
}
# User
atom-beautify, v0.29.7
autoclose-html, v0.23.0
file-icons, v1.7.11
project-plus, v0.9.0
# Dev
No dev packages
I'm getting the same issue for the first time just now.
Steps to reproduce.
Atom Version: 1.7.4
System: Microsoft Windows 7 Enterprise
Thrown From: atom-beautify package, v0.29.7
Uncaught TypeError: Cannot read property 'setScrollTop' of null
At C:\Users\cbr097\AppData\Local\atom\app-1.7.4\resources\app.asar\src\text-editor-element.js:372
TypeError: Cannot read property 'setScrollTop' of null
at atom-text-editor.TextEditorElement.setScrollTop (C:\Users\cbr097\AppData\Local\atom\app-1.7.4\resources\app.asar\src\text-editor-element.js:372:28)
at setScrollTop (file:///C:/Users/cbr097/.atom/packages/atom-beautify/src/beautify.coffee:35:8)
at file:///C:/Users/cbr097/.atom/packages/atom-beautify/src/beautify.coffee:131:13
34x -0:53.3.0 atom-terminal-panel:toggle-autocompletion (atom-text-editor.editor.vim-mode.normal-mode.is-focused)
-0:47.6.0 core:save (atom-text-editor.editor.vim-mode.normal-mode.is-focused)
{
"core": {
"customFileTypes": {
"source.ini": [
".buckconfig",
".flowconfig"
],
"source.json": [
".arcconfig",
"BUCK.autodeps"
],
"source.python": [
"BUCK"
]
},
"disabledPackages": [
"nuclide",
"atom-maven",
"linter-js-standard"
],
"ignoredNames": [
".hg",
".svn",
".DS_Store",
"._*",
"Thumbs.db"
]
},
"atom-beautify": {
"general": {
"_analyticsUserId": "687a717f-0f93-43e9-9b89-42493ba35b82"
},
"handlebars": {
"beautify_on_save": true,
"brace_style": "none",
"indent_inner_html": true,
"unformatted": [
"a",
"span",
"img",
"bdo",
"em",
"strong",
"dfn",
"code",
"samp",
"kbd",
"var",
"cite",
"abbr",
"acronym",
"q",
"sub",
"sup",
"tt",
"i",
"b",
"big",
"small",
"u",
"s",
"strike",
"font",
"ins",
"del",
"pre",
"address",
"dt",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"{{"
],
"wrap_attributes": "force"
},
"html": {
"beautify_on_save": true,
"indent_inner_html": true
},
"js": {
"beautify_on_save": true,
"indent_with_tabs": true
},
"json": {
"beautify_on_save": true,
"indent_with_tabs": true
},
"xml": {
"beautify_on_save": true
}
}
}
# User
atom-beautify, v0.29.7
atom-terminal-panel, v4.4.4
atom-xsltransform, v0.8.0
autocomplete-xml, v0.8.3
compare-files, v0.6.2
jQuery, v1.2.4
linter, v1.11.4
linter-javac, v1.9.4
vim-mode, v0.65.1
xml-tools, v0.2.1
# Dev
No dev packages
The same happening here.
All the time, saving .jsx files
+1, it's *.js in my case.
I thought that it might be trying to add a new line, and take it away, based on what happens to my cursor. I do have "end_with_newline": false set in my .jsbeautifyrc file.
Also, when the error does happen, the last line gets removed. When it doesn't happen, the last line is there.
I can "fix" it by restarting Atom.
I've already tried to fix this issue. Since I am unable to reproduce it, I will _need_ someone to submit a Pull Request and contribute a fix. The applicable function is setScrollTop found at https://github.com/Glavin001/atom-beautify/blob/master/src/beautify.coffee#L33-L35
Let me know if you have any questions.
For those having this issue please:
Thank you.
@Glavin001 I believe I have the exact steps to reproduce this issue.
Split RightIf I leave the editor open in the left pane I am able to beautify without any error.
This is not just js files, JSON files do this as well - any beautified file, I think.
What's weird is that the way it's triggered for me is without your step 2 above : if the file is opened in just one pane, I have no problem. If it's in more than one pane (like just after a split), the problem pops up.
+1
+1
I get the same error, could be useful the log?
@Nittarab Anything you could provide that would help us reproduce the defect would be helpful.
Atom Version: 1.11.2
Electron Version: 0.37.8
System: Ubuntu 16.04.1
Thrown From: atom-beautify package, v0.29.13
Uncaught TypeError: Cannot read property 'setScrollTop' of null
At /home/travis/build/atom/atom/out/app/src/text-editor-element.coffee:324
TypeError: Cannot read property 'setScrollTop' of null
at atom-text-editor.TextEditorElement.setScrollTop (/usr/share/atom/resources/app.asar/src/text-editor-element.js:324:28)
at setScrollTop (/home/patrick/.atom/packages/atom-beautify/src/beautify.coffee:35:9)
at /home/patrick/.atom/packages/atom-beautify/src/beautify.coffee:131:13
-4:15.1.0 core:paste (atom-text-editor.editor.is-focused)
30x -4:14.5.0 core:move-left (atom-text-editor.editor.is-focused)
-4:11.2.0 editor:move-to-end-of-screen-line (atom-text-editor.editor.is-focused)
-4:09.9.0 core:move-left (atom-text-editor.editor.is-focused)
-4:08.4.0 core:backspace (atom-text-editor.editor.is-focused)
6x -4:07.6.0 core:move-left (atom-text-editor.editor.is-focused)
3x -4:06.3.0 core:move-right (atom-text-editor.editor.is-focused)
7x -4:05.5.0 core:backspace (atom-text-editor.editor.is-focused)
3x -4:00.6.0 core:move-down (atom-text-editor.editor.is-focused.autocomplete-active)
-3:59.9.0 autocomplete-plus:confirm (atom-text-editor.editor.is-focused.autocomplete-active)
3x -3:59 core:move-right (atom-text-editor.editor.is-focused)
-3:56.2.0 core:paste (atom-text-editor.editor.is-focused)
5x -3:54.7.0 core:move-left (atom-text-editor.editor.is-focused)
9x -3:53.8.0 core:backspace (atom-text-editor.editor.is-focused)
-3:47.8.0 core:move-down (atom-text-editor.editor.is-focused.autocomplete-active)
-3:47.6.0 autocomplete-plus:confirm (atom-text-editor.editor.is-focused.autocomplete-active)
{
"core": {
"allowPendingPaneItems": false,
"disabledPackages": [
"activate-power-mode",
"linter-rubocop",
"comment"
],
"packagesWithKeymapsDisabled": [
"autoclose-html",
"processing"
],
"telemetryConsent": "limited",
"themes": [
"atom-material-ui",
"atom-material-syntax"
]
},
"atom-beautify": {
"apex": {},
"arduino": {},
"c": {},
"cfml": {},
"coffeescript": {
"disabled": true
},
"cpp": {},
"cs": {},
"css": {},
"d": {},
"ejs": {},
"erb": {
"beautify_on_save": true
},
"erlang": {
"beautify_on_save": true
},
"fortran": {},
"general": {
"_analyticsUserId": "4765caa8-330c-4cfe-9191-9a7eba029143"
},
"gherkin": {},
"handlebars": {},
"html": {},
"jade": {},
"java": {},
"js": {},
"json": {},
"jsx": {},
"latex": {},
"less": {},
"marko": {},
"mustache": {},
"objectivec": {},
"pawn": {},
"perl": {},
"php": {},
"python": {},
"riot": {},
"ruby": {},
"rust": {},
"sass": {},
"scss": {},
"spacebars": {},
"sql": {},
"svg": {},
"swig": {},
"tss": {},
"twig": {},
"typescript": {},
"vala": {},
"visualforce": {},
"xml": {},
"xtemplate": {}
}
}
# User
activate-power-mode, v1.1.0 (inactive)
atom-beautify, v0.29.13 (active)
atom-material-syntax, v0.4.6 (active)
atom-material-ui, v1.3.6 (active)
comment, v0.5.0 (inactive)
css-color-underline, v1.0.1 (active)
file-icons, v1.7.24 (active)
git-time-machine, v1.5.3 (inactive)
linter, v1.11.18 (active)
linter-coffeescript, v1.0.0 (active)
linter-gcc, v0.6.15 (active)
linter-rubocop, v0.5.0 (inactive)
merge-conflicts, v1.4.4 (active)
minimap, v4.25.6 (active)
processing, v0.13.0 (inactive)
wakatime, v6.0.10 (active)
atom-dark-syntax, v0.27.0 (inactive)
atom-dark-ui, v0.52.0 (inactive)
atom-light-syntax, v0.28.0 (inactive)
atom-light-ui, v0.44.0 (inactive)
base16-tomorrow-dark-theme, v1.2.0 (inactive)
base16-tomorrow-light-theme, v1.2.0 (inactive)
one-dark-ui, v1.6.0 (inactive)
one-light-ui, v1.6.0 (inactive)
one-dark-syntax, v1.3.0 (inactive)
one-light-syntax, v1.3.0 (inactive)
solarized-dark-syntax, v1.0.2 (inactive)
solarized-light-syntax, v1.0.2 (inactive)
about, v1.7.0 (active)
archive-view, v0.61.1 (active)
autocomplete-atom-api, v0.10.0 (active)
autocomplete-css, v0.11.2 (active)
autocomplete-html, v0.7.2 (active)
autocomplete-plus, v2.31.1 (active)
autocomplete-snippets, v1.11.0 (active)
autoflow, v0.27.0 (inactive)
autosave, v0.23.1 (active)
background-tips, v0.26.1 (active)
bookmarks, v0.42.0 (active)
bracket-matcher, v0.82.1 (active)
command-palette, v0.38.0 (inactive)
deprecation-cop, v0.54.1 (active)
dev-live-reload, v0.47.0 (active)
encoding-selector, v0.22.0 (active)
exception-reporting, v0.40.0 (active)
find-and-replace, v0.201.1 (inactive)
fuzzy-finder, v1.4.0 (active)
git-diff, v1.1.0 (active)
go-to-line, v0.31.0 (inactive)
grammar-selector, v0.48.2 (active)
image-view, v0.59.0 (active)
incompatible-packages, v0.26.1 (active)
keybinding-resolver, v0.35.0 (active)
line-ending-selector, v0.5.0 (active)
link, v0.31.1 (inactive)
markdown-preview, v0.158.0 (active)
metrics, v1.0.0 (active)
notifications, v0.65.1 (active)
open-on-github, v1.2.0 (inactive)
package-generator, v1.0.0 (inactive)
settings-view, v0.242.2-hotfix1 (active)
snippets, v1.0.2 (active)
spell-check, v0.68.2 (active)
status-bar, v1.4.1 (active)
styleguide, v0.47.0 (active)
symbols-view, v0.113.1 (inactive)
tabs, v0.101.0 (active)
timecop, v0.33.2 (active)
tree-view, v0.209.3 (active)
update-package-dependencies, v0.10.0 (active)
welcome, v0.35.1 (active)
whitespace, v0.33.0 (active)
wrap-guide, v0.38.2 (active)
language-c, v0.52.1 (active)
language-clojure, v0.21.0 (active)
language-coffee-script, v0.47.2 (active)
language-csharp, v0.12.1 (active)
language-css, v0.37.1 (active)
language-gfm, v0.88.0 (active)
language-git, v0.15.0 (active)
language-go, v0.42.1 (active)
language-html, v0.45.1 (active)
language-hyperlink, v0.16.0 (active)
language-java, v0.23.0 (active)
language-javascript, v0.119.0 (active)
language-json, v0.18.2 (active)
language-less, v0.29.5 (active)
language-make, v0.22.2 (active)
language-mustache, v0.13.0 (active)
language-objective-c, v0.15.1 (active)
language-perl, v0.35.0 (active)
language-php, v0.37.2 (active)
language-property-list, v0.8.0 (active)
language-python, v0.45.0 (active)
language-ruby, v0.69.0 (active)
language-ruby-on-rails, v0.25.0 (active)
language-sass, v0.56.0 (active)
language-shellscript, v0.22.4 (active)
language-source, v0.9.0 (active)
language-sql, v0.23.0 (active)
language-text, v0.7.1 (active)
language-todo, v0.28.0 (active)
language-toml, v0.18.0 (active)
language-xml, v0.34.9 (active)
language-yaml, v0.26.0 (active)
# Dev
No dev packages
``
I was able to reproduce with @gauravarora 's steps. The issue is with Atom's TextEditorElement.setScrollTop method when component = null. Simply checking if view.component exists before calling view.setScrollTop(value) will fix this. Since no one has submitted a Pull Request fixing this Issue since it was created in May, I will fix it now. Hopefully, in the future, others will be able to debug the issue and submit a Pull Request fixing issues like this.
Thank you everyone for reporting your issues and your steps to reproduce this issue.
Published to v0.29.16
Most helpful comment
This is not just js files, JSON files do this as well - any beautified file, I think.
What's weird is that the way it's triggered for me is without your step 2 above : if the file is opened in just one pane, I have no problem. If it's in more than one pane (like just after a split), the problem pops up.