Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setOption( "firstLineNumber", 0 ) only works correctly on scrollable and scrolled content #3265

Closed
FredGandt opened this issue Apr 8, 2017 · 4 comments

Comments

@FredGandt
Copy link

Setting the firstLineNumber to zero fails unless the code displayed is scrollable and has been scrolled.

Setting editor.setOptions( { "firstLineNumber": 0, "scrollPastEnd": true } ); will trick the first line number to show as zero on shorter content, but still only after the content has been scrolled enough to push the first line out of view.
On shorter content, without scrollPastEnd set, the first line number will always be empty.

Adding a hack to set the HTML textContent to zero on initializing ace, causes the first visible line number to always show as zero, even if, whilst scrolling, it should be something else.

FYI: Linden Scripting Language (LSL)'s line numbering starts at zero.

BTW: ace.js is great.

@nightwing
Copy link
Member

I can't reproduce this issue, when i run editor.setOptions( { "firstLineNumber": 0 } ); on https://ace.c9.io/ the 0 is shown correctly. Do you use an older version of the editor?

@FredGandt
Copy link
Author

FredGandt commented Apr 9, 2017

I downloaded the build from https://github.com/ajaxorg/ace-builds/ about 3 days ago.

Used the "editor.html" in the build as a template (just realised that it uses a <pre> instead of a <div> like the "...and use the code below" example at https://ace.c9.io/#nav=embedding which might make a difference?).

Am using the "src-min-noconflict", and to save explaining everything else, it's being served at http://fredgandts.website/lsl/editor/

You should see that until the code is scrolled, the zero is not shown.

Being JS, I should also have mentioned using Chrome (Version 57.0.2987.133) on Win7 Home Premium (SP1)

I am quite prepared to be told I'm doing it wrong, I just can't see how right now.

@nightwing
Copy link
Member

The link was very helpful, thanks!
The fix is at 597bd32

@FredGandt
Copy link
Author

I found var b=c=h?h.getText(t,v):v+l;b!=p.textNode.data&&(p.textNode.data=b),v++ in "ace.js" in "src-min-noconflict" and changed it to var b=c=h?h.getText(t,v):v+l;b!==p.textNode.data&&(p.textNode.data=b),v++ and am pleased to say it works. Thank you.

Reading minified code is slightly less fun than one might think ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants