daa84 / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
716 stars 57 forks source link

Characters disappear when NERDTree pane opens #255

Closed cyril-s closed 3 years ago

cyril-s commented 3 years ago

Describe the bug Some characters disappear when toggling NERDTree pane open, notably lines where NERDTree displays directories are affected.

nvim-gtk_bug

Technical information:

Reverting libpango to 1.44 fixes the issue

jacobmischka commented 3 years ago

I'm willing to bet #254 is related to this as well. I haven't dug into it yet, but I hope to soon (maybe not until hacktoberfest, though).

pitbuster commented 3 years ago

Hi @jacobmischka, have you had any chance to look into this?

I can help if needed (by running test, debugging, etc).

jacobmischka commented 3 years ago

I haven't, sorry.

theHamsta commented 3 years ago

I only had a short browse around the code base. What makes me a bit suspicious is this double_width. Could it be that neovim-gtk does not support triple-width, 4-byte characters? But it's only a guess since I didn't review it in detail It's just for ligatures

#[derive(Clone)]
pub struct Cell {
    pub hl: Rc<Highlight>,
    pub ch: String,
    pub dirty: bool,
    pub double_width: bool,
}

impl Cell {
    pub fn new_empty() -> Cell {
        Cell {
            hl: Rc::new(Highlight::new()),
            ch: String::new(),
            dirty: true,
            double_width: false,
        }
    }

    pub fn clear(&mut self, hl: Rc<Highlight>) {
        self.ch.clear();
        self.hl = hl;
        self.dirty = true;
        self.double_width = false;
    }
}

one usage

        for (cell_idx, cell) in line.line.iter().enumerate() {
            if cell.double_width {
                continue;
            }

            if !cell.ch.is_empty() {
                line_str.push_str(&cell.ch);
            } else {
                line_str.push(' ');
            }
            let len = line_str.len() - byte_offset;

            for _ in 0..len {
                cell_to_byte.push(cell_idx);
            }

            let next = style_attr.next(byte_offset, byte_offset + len, cell, hl);
            if let Some(next) = next {
                style_attr.insert_into(&attr_list);
                style_attr = next;
            }

            byte_offset += len;
        }

Could also be that those are double_with ligatures to be drawn. neovim-gtk has at least two character ligatures as -> . Should take a more detailed look.

  let len = line_str.len() - byte_offset;

But I suppose it has to be a byte != str.len issue.

cyril-s commented 3 years ago

After system upgrade the issue is fixed for me

cairo 1.17.4-3
glib2 2.66.4-2
gtk3 1:3.24.24-2
pango 1:1.48.1-1