@@ -766,11 +766,20 @@ export const use_handlers = (
766766 }
767767 }
768768
769+ if ( ( e . ctrlKey || e . metaKey ) && ! shiftKey && key . toLowerCase ( ) == 'c' ) {
770+ const selection = window . getSelection ( )
771+ if ( ! selection || selection . rangeCount === 0 || selection . isCollapsed ) {
772+ e . preventDefault ( )
773+ props . on_copy ( )
774+ return
775+ }
776+ }
777+
769778 if ( ( e . ctrlKey || e . metaKey ) && ! shiftKey ) {
770779 if ( key == 'ArrowLeft' ) {
771780 e . preventDefault ( )
772781 const raw_pos = raw_caret_pos_ref . current
773- if ( raw_pos === 0 ) return
782+ if ( raw_pos == 0 ) return
774783
775784 const { value, context_file_paths = [ ] } = props
776785 let i = raw_pos - 1
@@ -804,7 +813,7 @@ export const use_handlers = (
804813 const is_word_char = / \w / . test ( value [ i ] )
805814 while ( i >= 0 ) {
806815 const current_is_word = / \w / . test ( value [ i ] )
807- if ( / \s / . test ( value [ i ] ) || current_is_word !== is_word_char ) {
816+ if ( / \s / . test ( value [ i ] ) || current_is_word != is_word_char ) {
808817 break
809818 }
810819 i --
@@ -825,7 +834,7 @@ export const use_handlers = (
825834 e . preventDefault ( )
826835 const { value, context_file_paths = [ ] } = props
827836 const raw_pos = raw_caret_pos_ref . current
828- if ( raw_pos === value . length ) return
837+ if ( raw_pos == value . length ) return
829838
830839 let i = raw_pos
831840
@@ -867,7 +876,7 @@ export const use_handlers = (
867876 }
868877 }
869878
870- if ( ( e . ctrlKey || e . metaKey ) && ! shiftKey && key . toLowerCase ( ) === 'z' ) {
879+ if ( ( e . ctrlKey || e . metaKey ) && ! shiftKey && key . toLowerCase ( ) == 'z' ) {
871880 e . preventDefault ( )
872881 if ( undo_stack . length > 0 ) {
873882 const prev_entry = undo_stack [ undo_stack . length - 1 ]
@@ -888,8 +897,8 @@ export const use_handlers = (
888897 return
889898 }
890899 if (
891- ( ( e . ctrlKey || e . metaKey ) && key . toLowerCase ( ) === 'y' ) ||
892- ( ( e . ctrlKey || e . metaKey ) && shiftKey && key . toLowerCase ( ) === 'z' )
900+ ( ( e . ctrlKey || e . metaKey ) && key . toLowerCase ( ) == 'y' ) ||
901+ ( ( e . ctrlKey || e . metaKey ) && shiftKey && key . toLowerCase ( ) == 'z' )
893902 ) {
894903 e . preventDefault ( )
895904 if ( redo_stack . length > 0 ) {
0 commit comments