summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDexesTTP <dexes.ttp@gmail.com>2022-07-05 22:50:14 +0200
committerLinus Groh <mail@linusgroh.de>2022-07-06 11:12:45 +0200
commiteae8520dbbdce04bede469aa9fd0783c3d675cec (patch)
tree1ce82303b9951b9680bce775ebd9e95c118104d9
parente371552ff2d2cf3aabf65decc777dab3c34045b5 (diff)
downloadserenity-eae8520dbbdce04bede469aa9fd0783c3d675cec.zip
LibJS: Properly compute the line for source location hints
These were obvious wrong uses of the old default "only first occurence" parameter that was used in String::replace.
-rw-r--r--Userland/Libraries/LibJS/Parser.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Parser.h b/Userland/Libraries/LibJS/Parser.h
index 39a91c0cf3..d1f0ba0235 100644
--- a/Userland/Libraries/LibJS/Parser.h
+++ b/Userland/Libraries/LibJS/Parser.h
@@ -182,7 +182,7 @@ public:
return {};
// We need to modify the source to match what the lexer considers one line - normalizing
// line terminators to \n is easier than splitting using all different LT characters.
- String source_string = source.replace("\r\n", "\n", ReplaceMode::FirstOnly).replace("\r", "\n", ReplaceMode::FirstOnly).replace(LINE_SEPARATOR_STRING, "\n", ReplaceMode::FirstOnly).replace(PARAGRAPH_SEPARATOR_STRING, "\n", ReplaceMode::FirstOnly);
+ String source_string = source.replace("\r\n", "\n", ReplaceMode::All).replace("\r", "\n", ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\n", ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\n", ReplaceMode::All);
StringBuilder builder;
builder.append(source_string.split_view('\n', true)[position.value().line - 1]);
builder.append('\n');