Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coderai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
coderai
Commits
0950cd2f
Commit
0950cd2f
authored
Mar 01, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve multiline input handling - support paste, bracket detection, empty line finish
parent
3e4b1ca6
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1546 additions
and
6 deletions
+1546
-6
coder
coder
+54
-6
coder~
coder~
+1492
-0
No files found.
coder
View file @
0950cd2f
...
@@ -1092,14 +1092,59 @@ def run_interactive_shell(client: CoderClient, session_manager: SessionManager)
...
@@ -1092,14 +1092,59 @@ def run_interactive_shell(client: CoderClient, session_manager: SessionManager)
lines
=
[]
lines
=
[]
while
True
:
while
True
:
line
=
input
(
prompt
)
try
:
# Check if line ends with backslash for continuation
line
=
input
(
prompt
)
except
EOFError
:
# Handle Ctrl+D as end of multiline input
if
lines
:
break
raise
lines
.
append
(
line
)
# Check for explicit continuation with backslash
if
line
.
rstrip
()
.
endswith
(
'
\\
'
):
if
line
.
rstrip
()
.
endswith
(
'
\\
'
):
lines
.
append
(
line
.
rstrip
()[:
-
1
])
# Remove backslash
lines
[
-
1
]
=
line
.
rstrip
()[:
-
1
]
# Remove backslash
prompt
=
f
"{Colors.BLUE} ...>{Colors.RESET} "
# Continuation prompt
prompt
=
f
"{Colors.BLUE} ...>{Colors.RESET} "
# Continuation prompt
else
:
continue
lines
.
append
(
line
)
# Check for incomplete brackets (multiline paste detection)
joined
=
'
\n
'
.
join
(
lines
)
open_brackets
=
joined
.
count
(
'('
)
-
joined
.
count
(
')'
)
open_brackets
+=
joined
.
count
(
'['
)
-
joined
.
count
(
']'
)
open_brackets
+=
joined
.
count
(
'{'
)
-
joined
.
count
(
'}'
)
# Check for incomplete code blocks or sentences
stripped
=
line
.
strip
()
ends_with_colon
=
stripped
.
endswith
(
':'
)
ends_with_open
=
stripped
.
endswith
((
'('
,
'['
,
'{'
))
if
open_brackets
>
0
or
ends_with_colon
or
ends_with_open
:
prompt
=
f
"{Colors.BLUE} ...>{Colors.RESET} "
# Continuation prompt
continue
# Empty line after content - finish input (for paste mode)
if
not
stripped
and
len
(
lines
)
>
1
:
lines
.
pop
()
# Remove the empty line
break
break
# Single line input - we're done
if
len
(
lines
)
==
1
and
not
open_brackets
and
not
ends_with_colon
and
not
ends_with_open
:
break
# Multiple lines with balanced brackets - finish on empty line or new prompt
if
open_brackets
==
0
and
not
ends_with_colon
and
not
ends_with_open
:
# For pasted multiline content, finish immediately
# For manual entry, require empty line
if
'
\n
'
.
join
(
lines
)
.
count
(
'
\n
'
)
>=
1
and
not
stripped
:
lines
.
pop
()
# Remove the empty line
break
elif
'
\n
'
.
join
(
lines
)
.
count
(
'
\n
'
)
>=
1
and
stripped
:
# Pasted content with balanced brackets - likely done
break
else
:
prompt
=
f
"{Colors.BLUE} ...>{Colors.RESET} "
continue
user_input
=
'
\n
'
.
join
(
lines
)
.
strip
()
user_input
=
'
\n
'
.
join
(
lines
)
.
strip
()
...
@@ -1237,7 +1282,10 @@ def print_help():
...
@@ -1237,7 +1282,10 @@ def print_help():
{Colors.YELLOW}/confirm <tool> <y/n>{Colors.RESET} Enable/disable tool confirmation
{Colors.YELLOW}/confirm <tool> <y/n>{Colors.RESET} Enable/disable tool confirmation
{Colors.BOLD}{Colors.CYAN}Multiline Input:{Colors.RESET}
{Colors.BOLD}{Colors.CYAN}Multiline Input:{Colors.RESET}
End a line with {Colors.YELLOW}
\\
{Colors.RESET} to continue on next line
- End a line with {Colors.YELLOW}
\\
{Colors.RESET} to continue
- Or paste multiline content directly
- Or press Enter twice to finish
- Unclosed brackets ( ) [ ] {{ }} or : continue automatically
Example:
Example:
CoderCLI> This is a
\\
CoderCLI> This is a
\\
...> multiline message
...> multiline message
...
...
coder~
0 → 100755
View file @
0950cd2f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment