@@ -287,9 +287,11 @@ pub fn render_text<'t>(
287 style_span.0
287 style_span.0
290+ let virt = grapheme.is_virtual();
290 renderer.draw_grapheme(
291 renderer.draw_grapheme(
291 grapheme.grapheme,
292 grapheme.grapheme,
292 grapheme_style,
293 grapheme_style,
293 &mut last_line_indent_level,
295 &mut last_line_indent_level,
294 &mut is_in_indent_area,
296 &mut is_in_indent_area,
@@ -313,6 +315,7 @@ pub struct TextRenderer<'a> {
313 pub nbsp: String,
315 pub nbsp: String,
314 pub space: String,
316 pub space: String,
315 pub tab: String,
317 pub tab: String,
318+ pub virtual_tab: String,
316 pub indent_width: u16,
319 pub indent_width: u16,
317 pub starting_indent: usize,
320 pub starting_indent: usize,
318 pub draw_indent_guides: bool,
321 pub draw_indent_guides: bool,
@@ -342,6 +345,7 @@ impl<'a> TextRenderer<'a> {
343 " ".repeat(tab_width)
346 " ".repeat(tab_width)
348+ let virtual_tab = " ".repeat(tab_width);
345 let newline = if ws_render.newline() == WhitespaceRenderValue::All {
349 let newline = if ws_render.newline() == WhitespaceRenderValue::All {
346 ws_chars.newline.into()
350 ws_chars.newline.into()
@@ -370,6 +374,7 @@ impl<'a> TextRenderer<'a> {
373 whitespace_style: theme.get("ui.virtual.whitespace"),
378 whitespace_style: theme.get("ui.virtual.whitespace"),
374 indent_width,
379 indent_width,
375 starting_indent: col_offset / indent_width as usize
380 starting_indent: col_offset / indent_width as usize
@@ -392,6 +397,7 @@ impl<'a> TextRenderer<'a> {
392 &mut self,
397 &mut self,
393 grapheme: Grapheme,
398 grapheme: Grapheme,
394 mut style: Style,
399 mut style: Style,
395 last_indent_level: &mut usize,
401 last_indent_level: &mut usize,
396 is_in_indent_area: &mut bool,
402 is_in_indent_area: &mut bool,
397 position: Position,
403 position: Position,
@@ -405,14 +411,21 @@ impl<'a> TextRenderer<'a> {
407 let width = grapheme.width();
413 let width = grapheme.width();
414+ let space = if is_virtual { " " } else { &self.space };
415+ let nbsp = if is_virtual { " " } else { &self.nbsp };
416+ let tab = if is_virtual {
408 let grapheme = match grapheme {
421 let grapheme = match grapheme {
409 Grapheme::Tab { width } => {
422 Grapheme::Tab { width } => {
410− let grapheme_tab_width = char_to_byte_idx(&self.tab, width);
423+ let grapheme_tab_width = char_to_byte_idx(tab, width);
411− &self.tab[..grapheme_tab_width]
424+ &tab[..grapheme_tab_width]
413 // TODO special rendering for other whitespaces?
426 // TODO special rendering for other whitespaces?
414− Grapheme::Other { ref g } if g == " " => &self.space,
427+ Grapheme::Other { ref g } if g == " " => space,
415− Grapheme::Other { ref g } if g == "\u{00A0}" => &self.nbsp,
428+ Grapheme::Other { ref g } if g == "\u{00A0}" => nbsp,
416 Grapheme::Other { ref g } => g,
429 Grapheme::Other { ref g } => g,
417 Grapheme::Newline => &self.newline,
430 Grapheme::Newline => &self.newline,