mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
Shell: Fix completing barewords with escapes
e.g. completing `foo\ bar` now works as expected.
This commit is contained in:
parent
7059ca9b15
commit
9523bcbfe1
3 changed files with 43 additions and 21 deletions
|
@ -156,6 +156,7 @@ public:
|
|||
static String escape_token_for_single_quotes(const String& token);
|
||||
static String escape_token(const String& token);
|
||||
static String unescape_token(const String& token);
|
||||
static bool is_special(char c);
|
||||
|
||||
static bool is_glob(const StringView&);
|
||||
static Vector<StringView> split_path(const StringView&);
|
||||
|
@ -330,4 +331,21 @@ static constexpr bool is_word_character(char c)
|
|||
return c == '_' || (c <= 'Z' && c >= 'A') || (c <= 'z' && c >= 'a');
|
||||
}
|
||||
|
||||
inline size_t find_offset_into_node(const String& unescaped_text, size_t escaped_offset)
|
||||
{
|
||||
size_t unescaped_offset = 0;
|
||||
size_t offset = 0;
|
||||
for (auto& c : unescaped_text) {
|
||||
if (offset == escaped_offset)
|
||||
return unescaped_offset;
|
||||
|
||||
if (Shell::is_special(c))
|
||||
++offset;
|
||||
++offset;
|
||||
++unescaped_offset;
|
||||
}
|
||||
|
||||
return unescaped_offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue