accodeing / copy-with-style

An Atom package that allows you to copy syntax highlighted code to the clipboard.
MIT License
7 stars 11 forks source link

Uncaught TypeError: Cannot read property 'length' of undefined #6

Closed iouAkira closed 2 years ago

iouAkira commented 6 years ago

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.19.0 x64 Electron: 1.6.9 OS: Unknown Windows version Thrown From: copy-with-style package 1.1.0

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At C:\Users\Akira\.atom\packages\copy-with-style\lib\atom_editor.js:21

TypeError: Cannot read property 'length' of undefined
    at /packages/copy-with-style/lib/atom_editor.js:21:53)
    at HTMLgenerator.generate (/packages/copy-with-style/lib/html_generator.js:58:5)
    at Object.copy (/packages/copy-with-style/lib/main.js:58:68)
    at HTMLElement.copyWithStylePreset1 (/packages/copy-with-style/lib/main.js:19:45)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (~/AppData/Local/atom/app-1.19.0/resources/app/src/command-registry.js:265:35)
    at ~/AppData/Local/atom/app-1.19.0/resources/app/src/command-registry.js:3:65
    at Object.didConfirmSelection (~/AppData/Local/atom/app-1.19.0/resources/app/node_modules/command-palette/lib/command-palette-view.js:106:35)
    at SelectListView.confirmSelection (~/AppData/Local/atom/app-1.19.0/resources/app/node_modules/atom-select-list/src/select-list-view.js:313:26)
    at SelectListView.didClickItem (~/AppData/Local/atom/app-1.19.0/resources/app/node_modules/atom-select-list/src/select-list-view.js:228:16)
    at ListItemView.onclick (~/AppData/Local/atom/app-1.19.0/resources/app/node_modules/atom-select-list/src/select-list-view.js:168:37)
    at ListItemView.didClick (~/AppData/Local/atom/app-1.19.0/resources/app/node_modules/atom-select-list/src/select-list-view.js:361:16)

Commands

     -3:52.2.0 tree-view:show (atom-workspace.workspace.scrollbars-visible-always)
     -1:19.2.0 command-palette:toggle (input.hidden-input)
  3x -1:15 core:backspace (input.hidden-input)
  2x -1:12.8.0 core:move-down (input.hidden-input)
     -1:10.6.0 copy-with-style:preset1 (input.hidden-input)
     -1:03.6.0 application:open-folder (input.hidden-input)
     -0:52.4.0 application:open-file (input.hidden-input)

Non-Core Packages

atom-beautify 0.30.4 
atom-clock 0.1.13 
atom-material-syntax 1.0.6 
atom-material-syntax-dark 1.0.0 
atom-material-syntax-light 0.4.6 
atom-material-ui 2.0.4 
autoclose-html 0.23.0 
autocomplete-paths 1.0.5 
copy-with-style 1.1.0 
file-icons 2.1.10 
highlight-selected 0.13.1 
minimap 4.29.6 
minimap-highlight-selected 4.6.1 
monokai 0.24.0 
simplified-chinese-menu 5.3.4 
sync-settings 0.8.2 
tortoise-svn 0.5.1 
tree-view-finder 0.2.1 
d-Pixie commented 6 years ago

The error is on a line that reads:

this.lines = new Array( this.editor.buffer.lines.length );

What was in your window/selection at the time of invocation? How do I reproduce the error?

Basically it says that the editors buffer doesn't contain any lines.

s-light commented 6 years ago

iam getting the same error after updating atom from 1.18.0 to 1.20.0

in my freshly opened editor window was one file from the last session open. content of this file:

<!DOCTYPE html>
<html>
<head>
    <title>19:08</title>
</head>
<body>
    XYZ
</body>
</html>

i had all selected.

same error with a newly opened other file (tested with another random html file and an svg file)


Atom: 1.20.0 x64 Electron: 1.6.9 OS: Ubuntu 17.04 Thrown From: copy-with-style package 1.1.0

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At /home/stefan/.atom/packages/copy-with-style/lib/atom_editor.js:21

TypeError: Cannot read property 'length' of undefined
    at /packages/copy-with-style/lib/atom_editor.js:21:53)
    at HTMLgenerator.generate (/packages/copy-with-style/lib/html_generator.js:58:5)
    at Object.copy (/packages/copy-with-style/lib/main.js:58:68)
    at HTMLElement.copyWithStylePreset1 (/packages/copy-with-style/lib/main.js:19:45)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:265:35)
    at /usr/share/atom/resources/app/src/command-registry.js:3:65
    at Object.didConfirmSelection (/usr/share/atom/resources/app/node_modules/command-palette/lib/command-palette-view.js:106:35)
    at SelectListView.confirmSelection (/usr/share/atom/resources/app/node_modules/atom-select-list/src/select-list-view.js:313:26)
    at HTMLDivElement.core:confirm (/usr/share/atom/resources/app/node_modules/atom-select-list/src/select-list-view.js:81:20)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:265:35)
    at /usr/share/atom/resources/app/src/command-registry.js:3:65
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/usr/share/atom/resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/usr/share/atom/resources/app/src/window-event-handler.js:3:65)

Commands

     -2:51.1.0 editor:move-to-first-character-of-line (input.hidden-input)
     -2:50.4.0 editor:select-to-end-of-word (input.hidden-input)
     -2:49.8.0 core:backspace (input.hidden-input)
     -2:12.2.0 intentions:highlight (input.hidden-input)
     -2:12.1.0 core:save (input.hidden-input)
     -1:40.5.0 copy-with-style:copy (span.syntax--text.syntax--html.syntax--basic)
     -1:23.6.0 intentions:highlight (input.hidden-input)
     -1:23.5.0 core:select-all (input.hidden-input)
     -1:13.6.0 intentions:highlight (input.hidden-input)
     -1:13.4.0 core:select-all (input.hidden-input)
     -1:07.8.0 intentions:highlight (input.hidden-input)
     -1:07.6.0 command-palette:toggle (input.hidden-input)
  3x -1:05.6.0 core:move-down (input.hidden-input)
     -1:04.8.0 core:move-up (input.hidden-input)
     -1:03.9.0 core:confirm (input.hidden-input)
     -1:03.9.0 copy-with-style:preset1 (input.hidden-input)

Non-Core Packages

busy-signal 1.4.3 
copy-with-style 1.1.0 
fold-functions 0.5.0 
hey-pane 1.0.0 
highlight-selected 0.13.1 
intentions 1.1.5 
language-arduino 0.4.3 
language-latex 1.1.1 
language-pcb 1.0.1 
language-restructuredtext 1.1.0 
language-svg 0.9.2 
linter 2.2.0 
linter-eslint 8.2.1 
linter-gcc 0.7.1 
linter-jsonlint 1.3.0 
linter-markdown 5.2.0 
linter-pylama 0.9.4 
linter-shellcheck 1.4.6 
linter-spell 0.15.0 
linter-spell-html 0.7.0 
linter-spell-javascript 0.8.0 
linter-spell-project 0.2.0 
linter-spell-shellscript 0.2.0 
linter-stylelint 4.0.2 
linter-tidy 2.3.1 
linter-ui-default 1.6.8 
linter-xmllint 1.4.3 
markdown-pdf 2.1.0 
markdown-scroll-sync 2.1.2 
markdown-toc 0.4.2 
iouAkira commented 6 years ago

bugs like this?

s-light commented 6 years ago

@akyakya for me its the same behavior as in your 'video'

niccottrell commented 6 years ago

I get this too on Mac - happens with at least Javascript and Python code. For those who also have this? Is it on every file and type of selection?

milanify commented 5 years ago

Go to the settings of the add-on, and click "View code".

Go to the lib -> atom_editor.js file

Change line 21 to this.lines = new Array( this.editor.buffer.getLines().length );

Save the file

Close all your Atom windows and re-open them.

This will fix the .length() issue but now there is another issue with "onDidUpdateState" being called on null because "component.presenter" on line 58 of the atom_editor.js file is deprecated and so presenter is undefined, thus presenter.onDidUpdateState() will not work.

al-yakubovich commented 5 years ago

I have the same problem