Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7ca945

Browse files
committed
lib/mp-readline: Make it easy to exit auto-indent mode by pressing enter.
This patch allows you to stop auto-indent by pressing enter on a secondblank line. Easier than having to use backspace, and prevents new usersfrom getting stuck in auto-indent mode.
1 parente6dccaf commitb7ca945

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎docs/reference/repl.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Finally type ``print(i)``, press RETURN, press BACKSPACE and press RETURN again:
4949
3
5050
>>>
5151

52+
Auto-indent won't be applied if the previous two lines were all spaces. This
53+
means that you can finish entering a compound statment by pressing RETURN
54+
twice, and then a third press will finish and execute.
55+
5256
Auto-completion
5357
---------------
5458

‎lib/mp-readline/readline.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ STATIC void readline_auto_indent(void) {
370370
}
371371
}
372372
// i=start of line; j=first non-space
373+
if (i>0&&j+1==line->len) {
374+
// previous line is not first line and is all spaces
375+
for (size_tk=i-1;k>0;--k) {
376+
if (line->buf[k-1]=='\n') {
377+
// don't auto-indent if last 2 lines are all spaces
378+
return;
379+
}elseif (line->buf[k-1]!=' ') {
380+
// 2nd previous line is not all spaces
381+
break;
382+
}
383+
}
384+
}
373385
intn= (j-i) /4;
374386
if (line->buf[line->len-2]==':') {
375387
n+=1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp