Skip to content

Commit

Permalink
Merge branch 'gnatformat-issue_88' into '25.0'
Browse files Browse the repository at this point in the history
Do not indent rows that start with EOL

See merge request eng/libadalang/prettier-ada!38
  • Loading branch information
joaopsazevedo committed Oct 7, 2024
2 parents 8fc0463 + 1105bcd commit 26b0036
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/prettier_ada-documents-implementation.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,12 @@ package body Prettier_Ada.Documents.Implementation is
in Standard."+" (First_Row_Index, 1) .. Last_Row_Index
loop
Format_State.Result.Text.Append (End_Of_Line.Text);
Format_State.Result.Text.Append (Indentation.Value.Text);
if not States (Row_Index).Result.Text.Starts_With
(End_Of_Line.Text)
then
Format_State.Result.Text.Append
(Indentation.Value.Text);
end if;
Format_State.Result.Text.Append
(States (Row_Index).Result.Text);
end loop;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
183 changes: 183 additions & 0 deletions testsuite/tests/alignment_table/row_starts_with_eol/doc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"command": {
"break": false,
"command": "group",
"expandedStates": null,
"groupContents": {
"command": {
"command": "indent",
"indentContents": {
"id": 94,
"kind": "list",
"list": [
{
"id": 70,
"kind": "text",
"text": "Foooooooooooooo"
},
{
"id": 73,
"kind": "list",
"list": [
{
"command": {
"command": "line",
"hard": true,
"literal": false,
"soft": false
},
"id": 71,
"kind": "command"
},
{
"command": {
"command": "breakParent"
},
"id": 72,
"kind": "command"
}
]
},
{
"command": {
"breakParents": true,
"command": "alignmentTable",
"elements": [
[
{
"id": 74,
"kind": "text",
"text": "AAAAA"
},
{
"command": {
"break": false,
"command": "group",
"expandedStates": null,
"groupContents": {
"id": 80,
"kind": "list",
"list": [
{
"command": {
"command": "line",
"hard": false,
"literal": false,
"soft": false
},
"id": 78,
"kind": "command"
},
{
"id": 79,
"kind": "text",
"text": "BBBBB"
}
]
},
"id": 0
},
"id": 81,
"kind": "command"
}
],
[
{
"id": 92,
"kind": "list",
"list": [
{
"command": {
"command": "line",
"hard": true,
"literal": false,
"soft": false
},
"id": 82,
"kind": "command"
},
{
"command": {
"command": "breakParent"
},
"id": 83,
"kind": "command"
},
{
"id": 85,
"kind": "text",
"text": "CCC"
}
]
},
{
"command": {
"break": false,
"command": "group",
"expandedStates": null,
"groupContents": {
"id": 90,
"kind": "list",
"list": [
{
"command": {
"command": "line",
"hard": false,
"literal": false,
"soft": false
},
"id": 88,
"kind": "command"
},
{
"id": 89,
"kind": "text",
"text": "DDDD"
}
]
},
"id": 0
},
"id": 91,
"kind": "command"
}
]
],
"mustBreak": true,
"separators": [
[
{
"command": {
"command": "alignmentTableSeparator",
"text": ""
},
"id": 75,
"kind": "command"
}
],
[
{
"command": {
"command": "alignmentTableSeparator",
"text": ""
},
"id": 86,
"kind": "command"
}
]
]
},
"id": 93,
"kind": "command"
}
]
}
},
"id": 95,
"kind": "command"
},
"id": 0
},
"id": 96,
"kind": "command"
}
4 changes: 4 additions & 0 deletions testsuite/tests/alignment_table/row_starts_with_eol/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Foooooooooooooo
AAAAA BBBBB

CCC DDDD
4 changes: 4 additions & 0 deletions testsuite/tests/alignment_table/row_starts_with_eol/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: Table_Alignment row starts with EOL
driver: document_formatter
description: |
This test confirms that Table_Alignment does not add indentation to a row if it starts with EOL.

0 comments on commit 26b0036

Please sign in to comment.