@@ -92,19 +92,10 @@ export function initRepoEditor() {
92
92
} ) ;
93
93
94
94
const $editFilename = $ ( '#file-name' ) ;
95
- $editFilename . on ( 'keyup input' , function ( e ) {
96
- const $section = $ ( '.breadcrumb span.section' ) ;
97
- const $divider = $ ( '.breadcrumb div.divider' ) ;
95
+ $editFilename . on ( 'input' , function ( e ) {
98
96
let value ;
99
97
let parts ;
100
98
101
- if ( e . keyCode === 8 && getCursorPosition ( $ ( this ) ) === 0 && $section . length > 0 ) {
102
- value = $section . last ( ) . find ( 'a' ) . text ( ) ;
103
- $ ( this ) . val ( value + $ ( this ) . val ( ) ) ;
104
- $ ( this ) [ 0 ] . setSelectionRange ( value . length , value . length ) ;
105
- $section . last ( ) . remove ( ) ;
106
- $divider . last ( ) . remove ( ) ;
107
- }
108
99
parts = $ ( this ) . val ( ) . split ( '/' ) ;
109
100
if ( parts . length > 1 ) {
110
101
for ( let i = 0 ; i < parts . length ; ++ i ) {
@@ -133,6 +124,20 @@ export function initRepoEditor() {
133
124
$ ( '#tree_path' ) . val ( parts . join ( '/' ) ) ;
134
125
} ) ;
135
126
127
+ $editFilename . on ( 'keyup' , function ( e ) {
128
+ const $section = $ ( '.breadcrumb span.section' ) ;
129
+ const $divider = $ ( '.breadcrumb div.divider' ) ;
130
+ let value ;
131
+
132
+ if ( e . keyCode === 8 && getCursorPosition ( $ ( this ) ) === 0 && $section . length > 0 ) {
133
+ value = $section . last ( ) . find ( 'a' ) . text ( ) ;
134
+ $ ( this ) . val ( value + $ ( this ) . val ( ) ) ;
135
+ $ ( this ) [ 0 ] . setSelectionRange ( value . length , value . length ) ;
136
+ $section . last ( ) . remove ( ) ;
137
+ $divider . last ( ) . remove ( ) ;
138
+ }
139
+ } ) ;
140
+
136
141
const $editArea = $ ( '.repository.editor textarea#edit_area' ) ;
137
142
if ( ! $editArea . length ) return ;
138
143
0 commit comments