mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-17 23:01:01 +01:00
SPIGOT-6866: Fixed spaces a between comment indicator and actual comment
By: Wolf2323 <gabrielpatrikurban@gmail.com>
This commit is contained in:
parent
46d8d2cd11
commit
0503e4faed
3 changed files with 15 additions and 11 deletions
|
@ -204,7 +204,9 @@ public class YamlConfiguration extends FileConfiguration {
|
|||
if (comment.getCommentType() == CommentType.BLANK_LINE) {
|
||||
lines.add(null);
|
||||
} else {
|
||||
lines.add(comment.getValue());
|
||||
String line = comment.getValue();
|
||||
line = line.startsWith(" ") ? line.substring(1) : line;
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +219,9 @@ public class YamlConfiguration extends FileConfiguration {
|
|||
if (comment == null) {
|
||||
lines.add(new CommentLine(null, null, "", CommentType.BLANK_LINE));
|
||||
} else {
|
||||
lines.add(new CommentLine(null, null, comment, commentType));
|
||||
String line = comment;
|
||||
line = line.isEmpty() ? line : " " + line;
|
||||
lines.add(new CommentLine(null, null, line, commentType));
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
|
|
|
@ -373,7 +373,7 @@ public abstract class FileConfigurationTest extends MemoryConfigurationTest {
|
|||
config.options().parseComments(true);
|
||||
config.loadFromString("key1: value1\nkey2: value2 # Test inline\nkey3: value3");
|
||||
|
||||
assertEquals(Arrays.asList(" Test inline"), config.getInlineComments("key2"));
|
||||
assertEquals(Arrays.asList("Test inline"), config.getInlineComments("key2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -384,7 +384,7 @@ public abstract class FileConfigurationTest extends MemoryConfigurationTest {
|
|||
config.set("key1", "value1");
|
||||
config.set("key2", "value2");
|
||||
config.set("key3", "value3");
|
||||
config.setInlineComments("key2", Arrays.asList(" Test inline"));
|
||||
config.setInlineComments("key2", Arrays.asList("Test inline"));
|
||||
|
||||
String result = config.saveToString();
|
||||
String expected = "key1: value1\nkey2: value2 # Test inline\nkey3: value3\n";
|
||||
|
|
|
@ -16,15 +16,15 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
|||
@Override
|
||||
public List<String> getTestCommentInput() {
|
||||
List<String> comments = new ArrayList<>();
|
||||
comments.add(" This is a sample");
|
||||
comments.add(" header.");
|
||||
comments.add(" Newline above should be commented.");
|
||||
comments.add("This is a sample");
|
||||
comments.add("header.");
|
||||
comments.add("Newline above should be commented.");
|
||||
comments.add("");
|
||||
comments.add("");
|
||||
comments.add(null);
|
||||
comments.add(null);
|
||||
comments.add(" Comment of first Key");
|
||||
comments.add(" and a second line.");
|
||||
comments.add("Comment of first Key");
|
||||
comments.add("and a second line.");
|
||||
return comments;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
|||
|
||||
@Override
|
||||
public List<String> getTestHeaderComments() {
|
||||
return Arrays.asList(" Header", " Second Line");
|
||||
return Arrays.asList("Header", "Second Line");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
|||
|
||||
@Override
|
||||
public List<String> getTestKeyComments() {
|
||||
return Arrays.asList(" First key Comment", " Second Line");
|
||||
return Arrays.asList("First key Comment", "Second Line");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue