summaryrefslogtreecommitdiff
path: root/Userland/Applications/TextEditor
diff options
context:
space:
mode:
authorAli Chraghi <chraghiali1@gmail.com>2022-03-27 14:16:38 +0430
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-04-03 18:54:47 +0430
commit0eaed09517efd9731cc81a90e9e7fb6440d1e974 (patch)
tree770599ad6fbbe4dafc92a4f3418c012af9c82150 /Userland/Applications/TextEditor
parent5b48912d35d2cd7cbb0dde60a594429abadbd806 (diff)
downloadserenity-0eaed09517efd9731cc81a90e9e7fb6440d1e974.zip
TextEditor: Update file argument parser regex pattern
Diffstat (limited to 'Userland/Applications/TextEditor')
-rw-r--r--Userland/Applications/TextEditor/FileArgument.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Userland/Applications/TextEditor/FileArgument.cpp b/Userland/Applications/TextEditor/FileArgument.cpp
index e6acff471e..128103d22e 100644
--- a/Userland/Applications/TextEditor/FileArgument.cpp
+++ b/Userland/Applications/TextEditor/FileArgument.cpp
@@ -17,15 +17,14 @@ FileArgument::FileArgument(String file_argument)
m_column = {};
// A file doesn't exist with the full specified name, maybe the user entered line/column coordinates?
- Regex<PosixExtended> re("^(.+?)(:([0-9]+):?([0-9]+)?)?$");
+ Regex<PosixExtended> re("^(.+?)(?::([0-9]+))?(?::([0-9]+))?$");
RegexResult result = match(file_argument, re, PosixFlags::Global | PosixFlags::Multiline | PosixFlags::Ungreedy);
auto& groups = result.capture_group_matches.at(0);
// Match 0 group 0: file name
// Match 0 group 1: line number
// Match 0 group 2: column number
-
- if (groups.size() > 3) {
+ if (groups.size() > 2) {
// Both a line and column number were specified.
auto filename = groups.at(0).view.to_string();
auto initial_line_number = groups.at(1).view.to_string().to_int();
@@ -36,7 +35,7 @@ FileArgument::FileArgument(String file_argument)
m_line = initial_line_number.value();
if (initial_column_number.has_value())
m_column = initial_column_number.value();
- } else if (groups.size() == 3) {
+ } else if (groups.size() == 2) {
// Only a line number was specified.
auto filename = groups.at(0).view.to_string();
auto initial_line_number = groups.at(1).view.to_string().to_int();