File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -10854,6 +10854,16 @@ document.addEventListener("DOMContentLoaded", function (event) {
1085410854 }
1085510855
1085610856 function loadEditor ( ) {
10857+ function duplicateLine ( cm ) {
10858+ var current_cursor = cm . doc . getCursor ( ) ;
10859+ var line_content = cm . doc . getLine ( current_cursor . line ) ;
10860+ CodeMirror . commands . goLineEnd ( cm ) ;
10861+ CodeMirror . commands . newlineAndIndent ( cm ) ;
10862+ CodeMirror . commands . goLineLeft ( cm ) ;
10863+ cm . doc . replaceSelection ( line_content ) ;
10864+ cm . doc . setCursor ( current_cursor . line + 1 , current_cursor . ch ) ;
10865+ }
10866+
1085710867 editor = CodeMirror . fromTextArea ( document . getElementById ( "code" ) , {
1085810868 mode : "indent_text" ,
1085910869 lineWrapping : true ,
@@ -10898,7 +10908,9 @@ document.addEventListener("DOMContentLoaded", function (event) {
1089810908 cm . scrollIntoView ( ) ;
1089910909 } ,
1090010910 "Home" : "goLineLeftSmart" ,
10901- "End" : "goLineRight"
10911+ "End" : "goLineRight" ,
10912+ "Ctrl-D" : duplicateLine ,
10913+ "Cmd-D" : duplicateLine
1090210914 }
1090310915 } ) ;
1090410916 editor . setSize ( "100%" , "100%" ) ;
Original file line number Diff line number Diff line change @@ -112,6 +112,16 @@ document.addEventListener("DOMContentLoaded", function(event) {
112112 }
113113
114114 function loadEditor ( ) {
115+ function duplicateLine ( cm ) {
116+ var current_cursor = cm . doc . getCursor ( ) ;
117+ var line_content = cm . doc . getLine ( current_cursor . line ) ;
118+ CodeMirror . commands . goLineEnd ( cm ) ;
119+ CodeMirror . commands . newlineAndIndent ( cm ) ;
120+ CodeMirror . commands . goLineLeft ( cm ) ;
121+ cm . doc . replaceSelection ( line_content ) ;
122+ cm . doc . setCursor ( current_cursor . line + 1 , current_cursor . ch ) ;
123+ }
124+
115125 editor = CodeMirror . fromTextArea ( document . getElementById ( "code" ) , {
116126 mode : "indent_text" ,
117127 lineWrapping : true ,
@@ -149,7 +159,9 @@ document.addEventListener("DOMContentLoaded", function(event) {
149159 cm . scrollIntoView ( ) ;
150160 } ,
151161 "Home" : "goLineLeftSmart" ,
152- "End" : "goLineRight"
162+ "End" : "goLineRight" ,
163+ "Ctrl-D" : duplicateLine ,
164+ "Cmd-D" : duplicateLine ,
153165 }
154166 } ) ;
155167 editor . setSize ( "100%" , "100%" ) ;
You can’t perform that action at this time.
0 commit comments