Skip to content

Commit

Permalink
Correctly highlight variant values when several are set
Browse files Browse the repository at this point in the history
When one variant is set multiple times in the search query, correctly
highlight each of these variant values on matching modules.
  • Loading branch information
xdelaruelle committed Jun 24, 2023
1 parent c7278a6 commit 8db28ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tcl/report.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -1237,19 +1237,19 @@ proc prepareMapToHightlightSubstr {args} {
# Specific highlight translation map for variant name and value
proc prepareMapToHightlightVariant {args} {
set vrname_maplist {}
set vrval_maplist {}
if {[sgr hi {}] ne {}} {
foreach modspec $args {
foreach vrspec [getVariantListFromVersSpec $modspec] {
lassign $vrspec vrname vrvalue vrisbool
set maplist [list $vrname [sgr hi $vrname]]
# also highlight shortcut if any
if {[info exists ::g_variantShortcut($vrname)]} {
lappend maplist $::g_variantShortcut($vrname) [sgr hi\
$::g_variantShortcut($vrname)]
if {![info exists vrname_map($vrname)]} {
set maplist [list $vrname [sgr hi $vrname]]
# also highlight shortcut if any
if {[info exists ::g_variantShortcut($vrname)]} {
lappend maplist $::g_variantShortcut($vrname) [sgr hi\
$::g_variantShortcut($vrname)]
}
set vrname_map($vrname) $maplist
}
lappend vrname_maplist $vrname $maplist
# adapt variant value to highlight if boolean
set maplist {}
if {$vrisbool} {
Expand All @@ -1258,11 +1258,11 @@ proc prepareMapToHightlightVariant {args} {
set vrvalue [expr {$vrvalue ? {on} : {off}}]
}
lappend maplist $vrvalue [sgr hi $vrvalue]
lappend vrval_maplist $vrname $maplist
lappend vrval_map($vrname) {*}$maplist
}
}
}
return [list $vrname_maplist $vrval_maplist]
return [list [array get vrname_map] [array get vrval_map]]
}
# Format list of modules obtained from a getModules call in upper context
Expand Down
15 changes: 15 additions & 0 deletions testsuite/modules.70-maint/370-variant.exp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,21 @@ set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{bar=1,2,3:[sgr 1]foo[sgr 22]=[sgr
variant/7.0{[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],val2,val3}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1 baz=2} OK {}
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{[sgr 1]bar[sgr 22]=1,[sgr 1]2[sgr 22],3:[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],val2,[sgr 1]val3[sgr 22]}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1 bar=2 foo=val3} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{[sgr 1]bar[sgr 22]=[sgr 1]1[sgr 22],[sgr 1]2[sgr 22],3:[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],[sgr 1]val2[sgr 22],val3}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1 bar=2 foo=val2 bar=1} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{bar=1,2,3:[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],[sgr 1]val2[sgr 22],[sgr 1]val3[sgr 22]}
variant/7.0{[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],[sgr 1]val2[sgr 22],[sgr 1]val3[sgr 22]}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val3 foo=val1 foo=val2} OK $tserr
setenv_var TESTSUITE_VARIANT bool1
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{[sgr 1]bar[sgr 22]=on,[sgr 1]off[sgr 22]:[sgr 1]foo[sgr 22]=[sgr 1]on[sgr 22],[sgr 1]off[sgr 22]}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 +foo foo=off -bar} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{bar=on,off:[sgr 1]foo[sgr 22]=[sgr 1]on[sgr 22],[sgr 1]off[sgr 22]}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 +foo foo=off foo=on} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 -foo +foo} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=t foo=f} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=false foo=true} OK $tserr
unsetenv_var TESTSUITE_VARIANT

setenv_var MODULES_AVAIL_OUTPUT {modulepath:alias:dirwsym:sym:tag:variantifspec:key}
Expand Down

0 comments on commit 8db28ef

Please sign in to comment.