@@ -1326,6 +1326,26 @@ function commit_line(s)
1326
1326
state (s, mode (s)). ias = InputAreaState (0 , 0 )
1327
1327
end
1328
1328
1329
+ """
1330
+ `Base.LineEdit.tabwidth` controls the presumed tab width of code pasted into the REPL.
1331
+
1332
+ You can modify it by doing `eval(Base.LineEdit, :(tabwidth = 4))`, for example.
1333
+
1334
+ Must satisfy `0 < tabwidth <= 16`.
1335
+ """
1336
+ global tabwidth = 8
1337
+
1338
+ function bracketed_paste (s)
1339
+ ps = state (s, mode (s))
1340
+ input = readuntil (ps. terminal, " \e [201~" )[1 : (end - 6 )]
1341
+ input = replace (input, ' \r ' , ' \n ' )
1342
+ if position (buffer (s)) == 0
1343
+ indent = Base. indentation (input; tabwidth= tabwidth)[1 ]
1344
+ input = Base. unindent (input[(indent+ 1 ): end ], indent; tabwidth= tabwidth)
1345
+ end
1346
+ input
1347
+ end
1348
+
1329
1349
const default_keymap =
1330
1350
AnyDict (
1331
1351
# Tab
@@ -1429,13 +1449,7 @@ AnyDict(
1429
1449
" \e [3~" => (s,o... )-> edit_delete (s),
1430
1450
# Bracketed Paste Mode
1431
1451
" \e [200~" => (s,o... )-> begin
1432
- ps = state (s, mode (s))
1433
- input = readuntil (ps. terminal, " \e [201~" )[1 : (end - 6 )]
1434
- input = replace (input, ' \r ' , ' \n ' )
1435
- if position (buffer (s)) == 0
1436
- indent = Base. indentation (input; tabwidth= 4 )[1 ]
1437
- input = Base. unindent (input[(indent+ 1 ): end ], indent; tabwidth= 4 )
1438
- end
1452
+ input = bracketed_paste (s)
1439
1453
edit_insert (s, input)
1440
1454
end ,
1441
1455
" ^T" => (s,o... )-> edit_transpose (s)
0 commit comments