AlanDeSmet / human-resource-machine-viewer

Javascript to render Human Resource Machine programs similar to the original game.
GNU General Public License v3.0
9 stars 2 forks source link

Bug with line couning if first line is a comment not equal to -- HUMAN RESOURCE MACHINE PROGRAM -- #7

Closed caco3 closed 8 years ago

caco3 commented 8 years ago

Hi

I think I found a bug with the line counting in setActiveLine()

As far as I can see, if the first line contains -- HUMAN RESOURCE MACHINE PROGRAM --, it gets not shown and not counted. However, if the first line is a comment with any other text, it gets shown, but not counted. In the following example, I set the 5th line as active (setActiveLine(5)), but OUTBOX gets highlighted.

-- Test with invalid line count
INBOX 
COPYTO 1
SUB 0
SUB 2
OUTBOX
COPYFROM 0
AlanDeSmet commented 8 years ago

setActiveLine is counting all lines, including comments, including the special "-- HUMAN RESOURCE MACHINE PROGRAM --". It also indexes from 0. My thinking is that it's the one form of counting both my code and someone else's code can be certain to agree on.

I tried a variety of things, and I got the behavior I was expecting. For your example I would expect OUTBOX to be highlighted. If you're not seeing behavior that matches my description above, please let me know; I'd consider it a bug I should fix.

If you think it should have different behavior, I'd be interested in hearing what you're thinking.

Either way, thanks for letting me know!

caco3 commented 8 years ago

Thank you for looking into it. I tried to reproduce it again myself but failed. It might be that I had a bug in my surrounding code leading to my guess. As is now, it seems all to be ok.