Skip to content

[Q] How to use the linecache #29

@Cogitri

Description

@Cogitri

Hello,

It appears that I misuse the linecache (or I somehow discovered a weird bug, which may very well be in gxi though?). I'm not 100% certain how to trigger the behaviour I'm going to describe, but it usually happens after working on a document which is rather big for a while. At some point the linecache just bugs out, not giving me the right lines, which manifests s such stuff:

i: 760 line.text: 
i: 761 line.text:                 for x in line_selections {
i: 762 line.text:                 for x in line_selections {
i: 763 line.text:                     if let Some(cur) = begin_selection {
i: 764 line.text:                     if let Some(cur) = begin_selection {
i: 765 line.text:                     if let Some(cur) = begin_selection {
i: 766 line.text:                         // Make sure to use the lowest value of any selection so it's in the view
i: 767 line.text:                     }

The i is the line number (during drawing), the line.text is the text of the line. The duplicates shouldn't be there. Maybe I'm getting the lines during an update of the linecache? My drawing function is a bit primitive and just looks like this:

        for i in first_line..last_line {
            // Keep track of the starting x position
            if let Some(line) = self.line_cache.lines().get(i as usize) {
                 // draw each line with styles
            }
       }

This happens both with gxi using all of xrl and with xrl only using xrl's linecache (Cogitri/Tau@911c4e3 the commit is a bit broken due to rebasing, but after a tiny bit of fixing I could observe the same behaviour).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions