fix: add missing pos_to_width calls in add_diagnostic
This will fix the positioning of diagnostics in lines that have glyphs with widths != 1 like tabs or emojis.
This commit is contained in:
		
							parent
							
								
									39d4197a42
								
							
						
					
					
						commit
						e9a7d681f2
					
				
					 1 changed files with 13 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -3676,10 +3676,22 @@ pub const Editor = struct {
 | 
			
		|||
        code: []const u8,
 | 
			
		||||
        message: []const u8,
 | 
			
		||||
        severity: i32,
 | 
			
		||||
        sel: Selection,
 | 
			
		||||
        sel_: Selection,
 | 
			
		||||
    ) Result {
 | 
			
		||||
        if (!std.mem.eql(u8, file_path, self.file_path orelse return)) return;
 | 
			
		||||
 | 
			
		||||
        const root = self.buf_root() catch return;
 | 
			
		||||
        const sel: Selection = .{
 | 
			
		||||
            .begin = .{
 | 
			
		||||
                .row = sel_.begin.row,
 | 
			
		||||
                .col = root.pos_to_width(sel_.begin.row, sel_.begin.col, self.metrics) catch return,
 | 
			
		||||
            },
 | 
			
		||||
            .end = .{
 | 
			
		||||
                .row = sel_.end.row,
 | 
			
		||||
                .col = root.pos_to_width(sel_.end.row, sel_.end.col, self.metrics) catch return,
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        (try self.diagnostics.addOne()).* = .{
 | 
			
		||||
            .source = try self.diagnostics.allocator.dupe(u8, source),
 | 
			
		||||
            .code = try self.diagnostics.allocator.dupe(u8, code),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue