Skip to content

Commit

Permalink
feat: slightly change format, replace   with utf8 nbsp
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoKaios committed Aug 8, 2024
1 parent 326f29c commit c741f5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/lsp/cobol_lsp/lsp_data_info_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let max_value digits scale =
let decimal_part = Str.string_before (Str.string_after s whole) scale in
float_of_string (whole_part ^ "." ^ decimal_part)

let nbsp_repl = Str.global_replace (Str.regexp " ") " "
let nbsp_repl = Str.global_replace (Str.regexp " ") " " (* <- utf8 nbsp *)

let pp_example_of ppf (picture: Cobol_data.Picture.t) =
try
Expand All @@ -44,11 +44,12 @@ let pp_example_of ppf (picture: Cobol_data.Picture.t) =
if Float.is_integer max
then string_of_int (int_of_float max)
else string_of_float max in
Fmt.pf ppf "\n\nExample display values [%s] (0) [%s] (%s)"
Fmt.pf ppf "\n\n*e.g,* [`%s`] (0), [`%s`] (%s)"
(Lsp_picture_interp.example_of ~picture 0. |> nbsp_repl)
(Lsp_picture_interp.example_of ~picture max |> nbsp_repl)
max_str
| _ -> ()

with Invalid_argument _ -> ()

let pp_usage: usage Pretty.printer =
Expand Down
22 changes: 11 additions & 11 deletions test/lsp/lsp_hover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ let%expect_test "hover-typedef-vars" =
PIC 999 USAGE DISPLAY
```
NUMERIC(digits = 3, scale = 0, with_sign = false)
Example display values [000] (0) [123] (123)
*e.g,* [`000`] (0), [`123`] (123)
VALUE 123
(line 8, character 16):
__rootdir__/prog.cob:9.13-9.21:
Expand Down Expand Up @@ -391,7 +391,7 @@ let%expect_test "hover-typedef-vars" =
PIC 999 USAGE DISPLAY
```
NUMERIC(digits = 3, scale = 0, with_sign = false)
Example display values [000] (0) [123] (123)
*e.g,* [`000`] (0), [`123`] (123)
VALUE 123
(line 12, character 47):
__rootdir__/prog.cob:13.44-13.52:
Expand Down Expand Up @@ -465,7 +465,7 @@ let%expect_test "hover-typedef-vars-usage" =
PIC -BZZZ,ZZ9.99 USAGE DISPLAY
```
NUMERIC(digits = 8, scale = 2, with_sign = false)
Example display values [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.00] (0) [&nbsp;&nbsp;123,456.78] (123456.78)
*e.g,* [`        0.00`] (0), [`  123,456.78`] (123456.78)
(line 6, character 11):
__rootdir__/prog.cob:7.11-7.15:
4 DATA DIVISION.
Expand All @@ -482,7 +482,7 @@ let%expect_test "hover-typedef-vars-usage" =
PIC 9 USAGE BINARY
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1)
*e.g,* [`0`] (0), [`1`] (1)
(line 7, character 11):
__rootdir__/prog.cob:8.11-8.15:
5 WORKING-STORAGE SECTION.
Expand Down Expand Up @@ -558,7 +558,7 @@ let%expect_test "hover-typedef-vars-usage" =
PIC 9 USAGE PACKED-DECIMAL
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1)
*e.g,* [`0`] (0), [`1`] (1)
(line 12, character 11):
__rootdir__/prog.cob:13.11-13.15:
10 01 VAR6 PIC 111 USAGE BIT.
Expand All @@ -575,7 +575,7 @@ let%expect_test "hover-typedef-vars-usage" =
PIC $++/+.+B+ USAGE DISPLAY
```
NUMERIC(digits = 4, scale = 2, with_sign = false)
Example display values [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;] (0) [$+1/2.3&nbsp;4] (12.34) |}];;
*e.g,* [`         `] (0), [`$+1/2.3 4`] (12.34) |}];;

let%expect_test "hover-typedef-filler-vars" =
let { projdir; end_with_postproc }, server = make_lsp_project () in
Expand Down Expand Up @@ -813,7 +813,7 @@ let%expect_test "hover-typedef-renames" =
PIC 9 USAGE DISPLAY
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1)
*e.g,* [`0`] (0), [`1`] (1)
(line 8, character 16):
__rootdir__/prog.cob:9.10-9.25:
6 01 X.
Expand All @@ -831,7 +831,7 @@ let%expect_test "hover-typedef-renames" =
PIC 9 USAGE DISPLAY
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1)
*e.g,* [`0`] (0), [`1`] (1)
(line 8, character 23):
__rootdir__/prog.cob:9.23-9.24:
6 01 X.
Expand All @@ -848,7 +848,7 @@ let%expect_test "hover-typedef-renames" =
PIC 9 USAGE DISPLAY
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1)
*e.g,* [`0`] (0), [`1`] (1)
(line 9, character 22):
__rootdir__/prog.cob:10.13-10.22:
7 05 Y PIC 9.
Expand Down Expand Up @@ -884,7 +884,7 @@ let%expect_test "hover-typedef-renames" =
PIC 9 USAGE DISPLAY
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1) |}];;
*e.g,* [`0`] (0), [`1`] (1) |}];;

let%expect_test "hover-typedef-redefines" =
let { projdir; end_with_postproc }, server = make_lsp_project () in
Expand Down Expand Up @@ -939,7 +939,7 @@ let%expect_test "hover-typedef-redefines" =
PIC 9 USAGE DISPLAY
```
NUMERIC(digits = 1, scale = 0, with_sign = false)
Example display values [0] (0) [1] (1)
*e.g,* [`0`] (0), [`1`] (1)
(line 9, character 20):
__rootdir__/prog.cob:10.20-10.21:
7 05 Y PIC 9.
Expand Down
2 changes: 1 addition & 1 deletion test/lsp/lsp_picture_interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let unit_tests =
("Z,ZZZ.ZZ+", +123.456, " 123.45+");
("*,***.**+", -123.45, "**123.45-");
("**,***,***.**", +12345678.9, "12,345,678.90");
(* ("$Z,ZZZ,ZZZ.ZZCR", +12345.67, "$ 12,345.67"); *)
("$Z,ZZZ,ZZZ.ZZCR", +12345.67, "$ 12,345.67 ");
("$B*,***.**BBDB", 0., "*******.******");
("$B*,***,***.**BBDB", -12345.67, "$ ***12,345.67 DB");]

Expand Down

0 comments on commit c741f5f

Please sign in to comment.