mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 20:23:53 -07:00
SPIGOT-6866: Fixed spaces a between comment indicator and actual comment
By: Wolf2323 <gabrielpatrikurban@gmail.com>
This commit is contained in:
@@ -204,7 +204,9 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
if (comment.getCommentType() == CommentType.BLANK_LINE) {
|
if (comment.getCommentType() == CommentType.BLANK_LINE) {
|
||||||
lines.add(null);
|
lines.add(null);
|
||||||
} else {
|
} 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) {
|
if (comment == null) {
|
||||||
lines.add(new CommentLine(null, null, "", CommentType.BLANK_LINE));
|
lines.add(new CommentLine(null, null, "", CommentType.BLANK_LINE));
|
||||||
} else {
|
} 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;
|
return lines;
|
||||||
|
@@ -373,7 +373,7 @@ public abstract class FileConfigurationTest extends MemoryConfigurationTest {
|
|||||||
config.options().parseComments(true);
|
config.options().parseComments(true);
|
||||||
config.loadFromString("key1: value1\nkey2: value2 # Test inline\nkey3: value3");
|
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
|
@Test
|
||||||
@@ -384,7 +384,7 @@ public abstract class FileConfigurationTest extends MemoryConfigurationTest {
|
|||||||
config.set("key1", "value1");
|
config.set("key1", "value1");
|
||||||
config.set("key2", "value2");
|
config.set("key2", "value2");
|
||||||
config.set("key3", "value3");
|
config.set("key3", "value3");
|
||||||
config.setInlineComments("key2", Arrays.asList(" Test inline"));
|
config.setInlineComments("key2", Arrays.asList("Test inline"));
|
||||||
|
|
||||||
String result = config.saveToString();
|
String result = config.saveToString();
|
||||||
String expected = "key1: value1\nkey2: value2 # Test inline\nkey3: value3\n";
|
String expected = "key1: value1\nkey2: value2 # Test inline\nkey3: value3\n";
|
||||||
|
@@ -16,15 +16,15 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTestCommentInput() {
|
public List<String> getTestCommentInput() {
|
||||||
List<String> comments = new ArrayList<>();
|
List<String> comments = new ArrayList<>();
|
||||||
comments.add(" This is a sample");
|
comments.add("This is a sample");
|
||||||
comments.add(" header.");
|
comments.add("header.");
|
||||||
comments.add(" Newline above should be commented.");
|
comments.add("Newline above should be commented.");
|
||||||
comments.add("");
|
comments.add("");
|
||||||
comments.add("");
|
comments.add("");
|
||||||
comments.add(null);
|
comments.add(null);
|
||||||
comments.add(null);
|
comments.add(null);
|
||||||
comments.add(" Comment of first Key");
|
comments.add("Comment of first Key");
|
||||||
comments.add(" and a second line.");
|
comments.add("and a second line.");
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTestHeaderComments() {
|
public List<String> getTestHeaderComments() {
|
||||||
return Arrays.asList(" Header", " Second Line");
|
return Arrays.asList("Header", "Second Line");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,7 +45,7 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTestKeyComments() {
|
public List<String> getTestKeyComments() {
|
||||||
return Arrays.asList(" First key Comment", " Second Line");
|
return Arrays.asList("First key Comment", "Second Line");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user