@@ -294,7 +294,7 @@ def to_screen_lines(procs,  # type: List[px_process.PxProcess]
294294            max_cpu_time  =  proc .cpu_time_seconds 
295295            max_cpu_time_s  =  proc .cpu_time_s 
296296
297-     for  proc  in  procs :
297+     for  line_number ,  proc  in  enumerate ( procs ) :
298298        cpu_percent_s  =  proc .cpu_percent_s 
299299        if  proc .cpu_percent_s  ==  "0%" :
300300            cpu_percent_s  =  faint (cpu_percent_s .rjust (cpu_width ))
@@ -317,19 +317,13 @@ def to_screen_lines(procs,  # type: List[px_process.PxProcess]
317317            memory_percent_s , proc .cmdline )
318318
319319        cropped  =  line 
320-         if  columns  is  not None :
320+         if  row_to_highlight  ==  line_number :
321+             cropped  =  get_string_of_length (cropped , columns )
322+             cropped  =  inverse_video (cropped )
323+         elif  columns  is  not None :
321324            cropped  =  crop_ansi_string_at_length (line , columns )
322325        lines .append (cropped )
323326
324-     if  row_to_highlight  is  not None :
325-         # The "+ 1" here is to skip the heading line 
326-         highlighted  =  lines [row_to_highlight  +  1 ]
327-         highlighted  =  get_string_of_length (highlighted , columns )
328-         highlighted  =  inverse_video (highlighted )
329- 
330-         # The "+ 1" here is to skip the heading line 
331-         lines [row_to_highlight  +  1 ] =  highlighted 
332- 
333327    lines [0 ] =  heading_line 
334328
335329    return  lines 
@@ -396,14 +390,14 @@ def get_string_of_length(string, length):
396390    if  length  is  None :
397391        return  string 
398392
399-     incoming_length  =  visual_length (string )
400-     if  incoming_length  ==  length :
393+     initial_length  =  visual_length (string )
394+     if  initial_length  ==  length :
401395        return  string 
402396
403-     if  incoming_length  <  length :
404-         return  string  +  u' '  *  (length  -  incoming_length )
397+     if  initial_length  <  length :
398+         return  string  +  u' '  *  (length  -  initial_length )
405399
406-     if  incoming_length  >  length :
400+     if  initial_length  >  length :
407401        return  crop_ansi_string_at_length (string , length )
408402
409403    assert  False   # How did we end up here? 
0 commit comments