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 #8

Closed screamff closed 2 years ago

screamff commented 6 years ago

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.22.1 ia32 Electron: 1.6.15 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\Administrator\.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.handleCommandEvent (~/AppData/Local/atom/app-1.22.1/resources/app/src/command-registry.js:381:36)
    at Object.didConfirmSelection (~/AppData/Local/atom/app-1.22.1/resources/app/node_modules/command-palette/lib/command-palette-view.js:144:35)
    at SelectListView.confirmSelection (~/AppData/Local/atom/app-1.22.1/resources/app/node_modules/command-palette/node_modules/atom-select-list/src/select-list-view.js:327:26)
    at SelectListView.didClickItem (~/AppData/Local/atom/app-1.22.1/resources/app/node_modules/command-palette/node_modules/atom-select-list/src/select-list-view.js:242:16)
    at ListItemView.onclick (~/AppData/Local/atom/app-1.22.1/resources/app/node_modules/command-palette/node_modules/atom-select-list/src/select-list-view.js:181:39)
    at ListItemView.didClick (~/AppData/Local/atom/app-1.22.1/resources/app/node_modules/command-palette/node_modules/atom-select-list/src/select-list-view.js:375:16)

Commands

     -6:50.1.0 copy-as-rtf:copy (span.syntax--meta.syntax--function-call.syntax--arguments.syntax--python)
     -5:23.4.0 core:save (input.hidden-input)
     -5:13.3.0 copy-as-rtf:copy (div.line)
     -3:21.5.0 core:copy (input.hidden-input)
     -3:19.9.0 editor:copy-path (input.hidden-input)
  7x -3:11 core:backspace (input.hidden-input)
     -1:56.9.0 command-palette:toggle (input.hidden-input)
     -1:47.7.0 copy-with-style:preset1 (input.hidden-input)
     -1:12.4.0 command-palette:toggle (input.hidden-input)
     -1:03.3.0 pane:show-item-1 (input.hidden-input)
  6x -1:01.7.0 core:backspace (input.hidden-input)
     -0:59.4.0 copy-with-style:preset1 (input.hidden-input)
     -0:14.9.0 command-palette:toggle (input.hidden-input)
     -0:10.8.0 copy-with-style:preset2 (input.hidden-input)

Non-Core Packages

autocomplete-python 1.10.5 
copy-as-rtf 0.9.3 
copy-with-style 1.1.0 
file-icons 2.1.14 
highlight-selected 0.13.1 
simplified-chinese-menu 5.3.5 
thomasharris5109 commented 6 years ago

I have this issue too.

I tried to copy the code, running the package through the command pallette. It brought the error @screamff also had.

brettz9 commented 6 years ago

I have this also--working on Mac...

cbrdy commented 6 years ago

I have this issue too. Mine is windows 7 enterprise.

Ray-Airdog commented 6 years ago

I have this issue too on Linux, Fedora 27.

mahmud13 commented 6 years ago

I'm facing this issue too, on Ubuntu

jordiup commented 6 years ago

I'm having this issue too on windows 10

Uncaught TypeError: Cannot read property 'length' of undefined
C:\Users\Jordi\.atom\packages\copy-with-style\lib\atom_editor.js:21
Hide Stack Trace
TypeError: Cannot read property 'length' of undefined
    at new Editor (file:///C:/Users/Jordi/.atom/packages/copy-with-style/lib/atom_editor.js:21:53)
    at RTFgenerator.generate (file:///C:/Users/Jordi/.atom/packages/copy-with-style/lib/rtf_generator.js:47:5)
    at Object.copy (file:///C:/Users/Jordi/.atom/packages/copy-with-style/lib/main.js:56:67)
    at HTMLElement.copyWithStylePreset1 (file:///C:/Users/Jordi/.atom/packages/copy-with-style/lib/main.js:19:45)
    at CommandRegistry.handleCommandEvent (C:\Users\Jordi\AppData\Local\atom\app-1.27.2\resources\app\src\command-registry.js:384:49)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (C:\Users\Jordi\AppData\Local\atom\app-1.27.2\resources\app\node_modules\atom-keymap\lib\keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (C:\Users\Jordi\AppData\Local\atom\app-1.27.2\resources\app\node_modules\atom-keymap\lib\keymap-manager.js:412:28)
    at WindowEventHandler.handleDocumentKeyEvent (C:\Users\Jordi\AppData\Local\atom\app-1.27.2\resources\app\src\window-event-handler.js:110:40)
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.

pale2hall commented 5 years ago

I'm having this error too on MacOS High Sierra 10.13

Zireael commented 5 years ago

I get this issue as well. I've edited line 21 based on @milan102 suggestion and commented out lines 59, 62 that were throwing more errors, but now the command does nothing (nothing gets copied to Clipboard)

I'm on Win10.

abrunete commented 5 years ago

Same problem here on mac OSX, change in line 21 didn't fix the error.

Zack-83 commented 5 years ago

Same problem on Windows 10. Change in line 21 didn't help.

bernd-wechner commented 5 years ago

Ditto, on Win 10, changed line 21, no change.

robderon commented 4 years ago

Same issue here on mac os. Atom 1.41.0

eggrollofchaos commented 2 years ago

Same issue here on macOS Big Sur (11.2.3), Atom 1.58.0 Changing line 21 causes Issue #13