Skip to content

Commit

Permalink
Added fix for Strg+C in Firefox (#89)
Browse files Browse the repository at this point in the history
* bugfix Strg+C in Firefox sometimes changing selection

* added missing param type
  • Loading branch information
Gnietschow committed Feb 27, 2023
1 parent ae44ba0 commit f386c07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion codejar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P
}
}

if (isLegacy) restore(save())
if (isLegacy && !isCopy(event)) restore(save())
})

on('keyup', event => {
Expand Down Expand Up @@ -462,6 +462,10 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement, pos?: P
if (!key) return undefined
return (typeof key === 'string' ? key : String.fromCharCode(key)).toUpperCase()
}

function isCopy(event: KeyboardEvent) {
return isCtrl(event) && event.code === 'KeyC';
}

function insert(text: string) {
text = text
Expand Down

0 comments on commit f386c07

Please sign in to comment.