romgrk / termrk

Terminal for atom, using pty.js & term.js
MIT License
33 stars 7 forks source link

Uncaught TypeError: Cannot read property '0' of undefined #27

Closed wrick17 closed 9 years ago

wrick17 commented 9 years ago

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.0.0 System: Mac OS X 10.10.3 Thrown From: Termrk package, v0.1.17

Stack Trace

Uncaught TypeError: Cannot read property '0' of undefined

At /Users/wrick17/.atom/packages/Termrk/node_modules/term.js/src/term.js:1208

TypeError: Cannot read property '0' of undefined
  at Terminal.refresh (/Users/wrick17/.atom/packages/Termrk/node_modules/term.js/src/term.js:1208:18)
  at Terminal.refresh (/Users/wrick17/.atom/packages/Termrk/lib/termjs-fix.coffee:127:9)
  at Terminal._cursorBlink (/Users/wrick17/.atom/packages/Termrk/node_modules/term.js/src/term.js:1324:8)
  at _blinker (/Users/wrick17/.atom/packages/Termrk/node_modules/term.js/src/term.js:1341:10)

Commands

     -5:30.6.0 settings-view:open (atom-text-editor.editor.is-focused)
     -5:26.2.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -4:24.3.0 editor:move-to-first-character-of-line (atom-text-editor.editor.mini.is-focused)
     -4:22.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -2:51.2.0 editor:delete-to-beginning-of-line (atom-text-editor.editor.mini.is-focused)
  2x -2:49.7.0 core:backspace (atom-text-editor.editor.mini.is-focused)
  2x -2:49.1.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -1:41.4.0 pane:show-next-item (div.settings-view.pane-item)
     -1:39.6.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -1:37.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
  7x -1:37.4.0 termrk:toggle (atom-text-editor.editor)

Config

{
  "core": {
    "themes": [
      "seti-ui",
      "seti-syntax"
    ],
    "disabledPackages": [
      "term2"
    ]
  }
}

Installed Packages

# User
Termrk, v0.1.17
pigments, v0.8.1
set-syntax, v0.3.0
seti-syntax, v0.4.0
seti-ui, v0.7.1

# Dev
No dev packages
viernullvier commented 9 years ago

Steps to reproduce:

  1. Enter new lines until the terminal reaches the bottom of the window
  2. Scroll up
ghost commented 9 years ago

Hello all,

I corrected this issue by modifing the terminalMousewheel event in lib/termk-view.coffee file, as follows:


terminalMousewheel: (event) =>
        deltaY  = event.wheelDeltaY
     #This line breaks things on OS X 
     #deltaY/120 is not needed for scrolling
        #deltaY /= 120
        deltaY *= -1
        @terminal.scrollDisp(deltaY)

michael4reynolds commented 9 years ago

I still get this error when attempting to scroll up to the previous text.

wrick17 commented 9 years ago

Hey @ZachR0, I tried your fix, but it still throws the same error for me. any idea what might be the problem?

ghost commented 9 years ago

@basheps @wrick17 I have not tested this fix outside of OS X; From what I can tell, the way that the delta Y values from the "mouse wheel" are being used is causing the problem. Depending on your operating system, the way in which this value is interpreted varies. If this is the case, the way this mouse event is handled needs to be universal.

Mozilla has some good documentation talking about these delta values - https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel

After you two made these changes, did you close and re-open Atom? Also, what operating system are you using?

ghost commented 9 years ago

@basheps @wrick17 This solution works for me as well, does it work on your end? I changed how scrolling was handled -- I pretty much looked how term.js does it, and converted it over to CoffeeScript.


terminalMousewheel: (event) =>
        #This breaks everything :(
        #deltaY  = event.wheelDeltaY
        #deltaY /= 120
        #deltaY *= -1
        #Works on OSX only?
        #deltaY = event.wheelDeltaY
        #deltaY *= -1
        #Possible catch-all solution?
        deltaY = event.wheelDeltaY
        #Handle scrolling based on the event type
        #Based on how term.js handles mouse scrolling
        if event.type is 'DOMMouseScroll'
          deltaY += if event.detail < 0 then -1 else 1
          deltaY *= -1 #Correct scrolling direction
        else
          deltaY += if event.wheelDeltaY > 0 then -1 else 1
          deltaY *= -1 #Correct scrolling direction
        @terminal.scrollDisp(deltaY)

romgrk commented 9 years ago

Closing in favor of https://github.com/romgrk/termrk/issues/27.