Skip to content

Commit

Permalink
Merge pull request #5364 from rjbou/header-msg-space
Browse files Browse the repository at this point in the history
Fix trailing space on header messages
  • Loading branch information
rjbou authored Nov 24, 2022
2 parents b540b2e + ec49308 commit e92efa8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,4 @@ users)
* `OpamFilename.clean_dir`: as the directory is recreated after removal, checks that the directory exists beforhand. It avoid creating a new empty directory uselessly [#4967 @rjbou]
* `OpamStd.Map`: add `filter_map` [#5337 @rjbou]
* `OpamStd.Set`: Add `to_list_map` [#5308 @kit-ty-kate]
* `OpamConsole.header_msg`: remove trailing space when there is no left padding [#5363 @rjbou]
4 changes: 2 additions & 2 deletions src/core/opamConsole.ml
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,14 @@ let header_msg fmt =
let wpad = header_width () - String.length str - 2 in
let wpadl = 4 in
let wpadr = wpad - wpadl - if utf8_extended () then 4 else 0 in
print_message `stdout "\n%s %s %s%s\n"
print_message `stdout "\n%s %s%s%s\n"
(colorise `cyan (String.sub padding 0 wpadl))
(colorise `bold str)
(if wpadr > 0 then
let padding =
String.sub padding (String.length padding - wpadr) wpadr
in
colorise `cyan padding
" " ^ colorise `cyan padding
else
"")
(if wpadr >= 0 && utf8_extended () then
Expand Down
6 changes: 3 additions & 3 deletions tests/reftests/init.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Configuring from ${BASEDIR}/opamrc and then from built-in defaults.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised

<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-base-compiler)
<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-base-compiler)

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]
Expand All @@ -34,7 +34,7 @@ Configuring from ${BASEDIR}/opamrc and then from built-in defaults.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised

<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-base-compiler)
<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-base-compiler)

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]
Expand All @@ -58,7 +58,7 @@ Configuring from ${BASEDIR}/opamrc and then from built-in defaults.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised

<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-system)
<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-system)

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]
Expand Down

0 comments on commit e92efa8

Please sign in to comment.