Further improve text-file ending requirements#306
Further improve text-file ending requirements#306greenc-FNAL wants to merge 1 commit intoFramework-R-D:mainfrom
Conversation
greenc-FNAL
commented
Feb 10, 2026
- Copilot managed to misinterpret the existing instructions—again; now fixed.
- Copilot managed to misinterpret the existing instructions—again; now fixed.
There was a problem hiding this comment.
Pull request overview
This PR refines the text file formatting instructions in the Copilot guidelines to address previous misinterpretations. The changes aim to clarify requirements for file endings, specifically that files must end with exactly one newline and no trailing blank lines or whitespace.
Changes:
- Rewrote the file ending requirement to explicitly state that the final character must be a newline and the preceding character must not be a newline or whitespace
- Added an exception for multi-line strings to the trailing whitespace prohibition
|
|
||
| - All text files must have their final line be non-empty and terminated with a single newline character, leaving no trailing blank lines | ||
| - **Never add trailing whitespace on any line** (spaces or tabs at end of lines) | ||
| - For all text files, the final character in the file **must** be a newline character, and the immediately-preceding character **must not** be either a newline character or other whitespace (space, tab, etc.) |
There was a problem hiding this comment.
The new wording in line 105 creates potential confusion about blank lines within files. The phrase "the immediately-preceding character must not be either a newline character" could be misinterpreted to mean that blank lines are never allowed, since blank lines consist of consecutive newline characters.
The intention appears to be: "files must end with exactly one newline character, and there must be no trailing blank lines at the end of the file." However, the current wording about "immediately-preceding character" doesn't clearly distinguish between legitimate blank lines within the file content versus prohibited trailing blank lines at the end.
Consider rewording to be more explicit, such as: "For all text files, the final character must be a newline character, and there must be no trailing blank lines or trailing whitespace at the end of the file."
| - For all text files, the final character in the file **must** be a newline character, and the immediately-preceding character **must not** be either a newline character or other whitespace (space, tab, etc.) | |
| - For all text files, the final character in the file **must** be a newline character, and there **must not** be any additional blank lines or trailing whitespace at the end of the file |
| - All text files must have their final line be non-empty and terminated with a single newline character, leaving no trailing blank lines | ||
| - **Never add trailing whitespace on any line** (spaces or tabs at end of lines) | ||
| - For all text files, the final character in the file **must** be a newline character, and the immediately-preceding character **must not** be either a newline character or other whitespace (space, tab, etc.) | ||
| - **Never add trailing whitespace on any line** (spaces or tabs at end of lines) unless it is part of a multi-line string |
There was a problem hiding this comment.
The exception "unless it is part of a multi-line string" is ambiguous and could lead to inconsistent behavior. In most programming contexts, trailing whitespace within multi-line strings is preserved by the language runtime, not by the source file format.
Questions arise: Does this mean Copilot should add trailing whitespace to multi-line string literals when the string content requires it? Should it preserve trailing whitespace that already exists in multi-line strings even if it's not semantically meaningful? What about YAML multi-line strings, heredocs, or template literals?
Consider either removing this exception (letting language semantics handle multi-line string whitespace) or providing specific examples of when this exception applies. The blanket exception may create more confusion than it resolves.
| - **Never add trailing whitespace on any line** (spaces or tabs at end of lines) unless it is part of a multi-line string | |
| - **Never add trailing whitespace on any line** (spaces or tabs at end of lines) |
|
|
||
| - All text files must have their final line be non-empty and terminated with a single newline character, leaving no trailing blank lines | ||
| - **Never add trailing whitespace on any line** (spaces or tabs at end of lines) | ||
| - For all text files, the final character in the file **must** be a newline character, and the immediately-preceding character **must not** be either a newline character or other whitespace (space, tab, etc.) |
There was a problem hiding this comment.
The phrase "other whitespace (space, tab, etc.)" in line 105 creates a technical contradiction with line 106. Line 105 prohibits any whitespace before the final newline, but line 106 says "Never add trailing whitespace on any line" - implying that the issue is trailing whitespace on lines, not before the file's final newline.
If line 105 is interpreted literally as written, it would prohibit files ending with patterns like "content \n" (where there's a space after content), which would be redundantly covered by the line 106 rule about trailing whitespace on lines.
The phrase "or other whitespace (space, tab, etc.)" should be removed from line 105, as the trailing whitespace rule in line 106 already covers this case. Line 105 should focus solely on the "no trailing blank lines" requirement, meaning the character before the final newline must not be another newline.
| - For all text files, the final character in the file **must** be a newline character, and the immediately-preceding character **must not** be either a newline character or other whitespace (space, tab, etc.) | |
| - For all text files, the final character in the file **must** be a newline character, and the immediately-preceding character **must not** be another newline character (no trailing blank lines) |
|
Review the full CodeQL report for details. |