@@ -245,15 +245,10 @@ impl EditorView {
245 acc.patch(style)
245 acc.patch(style)
248− // TODO: we could render the text to a surface, then cache that, that
249− // way if only the selection/cursor changes we can copy from cache
250− // and paint the new cursor.
251− // We could keep a single resizable surface on the View for that.
253− // iterate over range char by char
254 for grapheme in RopeGraphemes::new(text) {
248 for grapheme in RopeGraphemes::new(text) {
255 let out_of_bounds = visual_x < view.first_col as u16
249 let out_of_bounds = visual_x < view.first_col as u16
256 || visual_x >= viewport.width + view.first_col as u16;
250 || visual_x >= viewport.width + view.first_col as u16;
257 if LineEnding::from_rope_slice(&grapheme).is_some() {
252 if LineEnding::from_rope_slice(&grapheme).is_some() {
258 if !out_of_bounds {
253 if !out_of_bounds {
259 // we still want to render an empty cell with the style
254 // we still want to render an empty cell with the style
@@ -272,42 +267,30 @@ impl EditorView {
272 if line >= viewport.height {
267 if line >= viewport.height {
273 break 'outer;
268 break 'outer;
275− } else if grapheme == "\t" {
277− // if we're offscreen just keep going until we hit a new line
278− visual_x = visual_x.saturating_add(tab_width as u16);
282− // we still want to render an empty cell with the style
284− viewport.x + visual_x - view.first_col as u16,
290− visual_x = visual_x.saturating_add(tab_width as u16);
292− // Cow will prevent allocations if span contained in a single slice
293− // which should really be the majority case
294 let grapheme = Cow::from(grapheme);
271 let grapheme = Cow::from(grapheme);
295− let width = grapheme_width(&grapheme) as u16;
273+ let (grapheme, width) = if grapheme == "\t" {
274+ // make sure we display tab as appropriate amount of spaces
275+ (tab.as_str(), tab_width)
277+ // Cow will prevent allocations if span contained in a single slice
278+ // which should really be the majority case
279+ let width = grapheme_width(&grapheme);
280+ (grapheme.as_ref(), width)
297− if out_of_bounds {
283+ if !out_of_bounds {
298 // if we're offscreen just keep going until we hit a new line
284 // if we're offscreen just keep going until we hit a new line
299− visual_x = visual_x.saturating_add(width);
285+ surface.set_string(
300− continue;
286+ viewport.x + visual_x - view.first_col as u16,
303− surface.set_string(
293+ visual_x = visual_x.saturating_add(width as u16);
304− viewport.x + visual_x - view.first_col as u16,