@@ -238,18 +238,14 @@ static void window_draw_ruler(struct window *window) {
238238 tb_string (W2S (w - strlen (ruler ) - 1 , h ), fg , bg , ruler );
239239}
240240
241- static void window_draw_line_number (struct window * window , size_t line ) {
241+ static void window_draw_line_number (struct window * window , size_t line , size_t cursorline ) {
242242 bool number = window -> opt .number ;
243243 bool relativenumber = window -> opt .relativenumber ;
244244
245245 if (!number && !relativenumber ) {
246246 return ;
247247 }
248248
249- size_t cursorline , cursorcol ;
250- gb_pos_to_linecol (window -> buffer -> text , window_cursor (window ),
251- & cursorline , & cursorcol );
252-
253249 size_t linenumber = line + 1 ;
254250 if (relativenumber && !(number && line == cursorline )) {
255251 linenumber = (size_t ) labs ((ssize_t )(line - cursorline ));
@@ -310,6 +306,10 @@ static void window_draw_leaf(struct window *window, struct editor *editor) {
310306 size_t numberwidth = window_numberwidth (window );
311307 int tabstop = window -> buffer -> opt .tabstop ;
312308
309+ size_t cursorline , cursorcol ;
310+ gb_pos_to_linecol (window -> buffer -> text , window_cursor (window ),
311+ & cursorline , & cursorcol );
312+
313313 struct syntax syntax ;
314314 struct syntax_token token = {SYNTAX_TOKEN_NONE , 0 , 0 };
315315 bool highlight = syntax_init (& syntax , window -> buffer );
@@ -321,7 +321,7 @@ static void window_draw_leaf(struct window *window, struct editor *editor) {
321321
322322 for (size_t y = 0 ; y < rows ; ++ y ) {
323323 size_t line = y + window -> top ;
324- window_draw_line_number (window , line );
324+ window_draw_line_number (window , line , cursorline );
325325
326326 if (y > 0 ) {
327327 line_pos += gb -> lines -> buf [line - 1 ] + 1 ;
0 commit comments