mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
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.
This commit is contained in:
parent
e371552ff2
commit
eae8520dbb
Notes:
sideshowbarker
2024-07-17 09:40:36 +09:00
Author: https://github.com/Dexesttp Commit: https://github.com/SerenityOS/serenity/commit/eae8520dbb Pull-request: https://github.com/SerenityOS/serenity/pull/14497 Reviewed-by: https://github.com/linusg ✅
@ -182,7 +182,7 @@ public:
|
|||||||
return {};
|
return {};
|
||||||
// We need to modify the source to match what the lexer considers one line - normalizing
|
// 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.
|
// 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;
|
StringBuilder builder;
|
||||||
builder.append(source_string.split_view('\n', true)[position.value().line - 1]);
|
builder.append(source_string.split_view('\n', true)[position.value().line - 1]);
|
||||||
builder.append('\n');
|
builder.append('\n');
|
||||||
|
Loading…
Reference in New Issue
Block a user