Code Monkey home page Code Monkey logo

Comments (5)

oOosys avatar oOosys commented on September 27, 2024

The crash is caused by view.wrap_count(line_no) call when given too large line_no. The original reason for this is that in wrapping mode active_view.first_visible_line does not report the line number seen as line number in the line numbering margin, but some other value which is much higher and changes when scrolling one line at a time by values like for example 10 or 15 at a time.

In other words the crash occurs because view.first_visible_line does not report the actual first visible line number seen in the line numbering margin with switched on line wrapping.

Is it a bug or a feature that view.first_visible_line does not provide the right line number if wrapping is switched on? How to detect if wrapping is active from within Lua code in user init.lua?

from textadept.

orbitalquark avatar orbitalquark commented on September 27, 2024

I haven't looked at your code, but my first instinct is that you need to call view:doc_line_from_visible(view.first_visible_line) to get the actual document/buffer line number from the one displayed/visible. This is a feature of Scintilla, not a bug.

from textadept.

oOosys avatar oOosys commented on September 27, 2024

OK ... So view.first_visible_line gives a line number which is the result of counting lines as they would appear in the view on screen. i.e. If an actual document line N (counted by newlines in the file of the loaded viewed text if the text was not yet changed) is wrapped into five lines, navigating to the last of these lines will give view.first_visible_line==N+4 where view:doc_line_from_visible(view.first_visible_line)==N will still give the in the line numbering margin shown line number N.
In other words, switching line wrapping ON results in converting the entire viewed buffer text into wrapped text, not only the part which is visible in the view, right? So wrapping lines in case of very large documents will result in making the CPU busy with recalculating all the line numbers in the entire document and should be avoided as not practicable, right?
Further in other words, if I want wrapping of long lines in texts with a huge amount of long lines I need to implement it on my own and take full control of what is displayed in the view, no matter the actual content of the viewed text, right?

from textadept.

orbitalquark avatar orbitalquark commented on September 27, 2024

Your understanding is correct. I doubt you can "tak[e] full control of what is displayed in the view" though. Scintilla (via GUI widget) has its own way of displaying/laying out text that Textadept does not interfere with.

from textadept.

oOosys avatar oOosys commented on September 27, 2024

Thanks for the hint towards view:doc_line_from_visible(view.first_visible_line). This is a perfect starting point for "print()-based" debugging and understanding what is going on with the side-effect of solving the problem which was the reason for opening this issue. That the application shouldn't crash given a wrong value for a line number is another topic I am currently not ready to cope with.

from textadept.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.