Skip to content

Commit

Permalink
Disable opcode suggestion on paste
Browse files Browse the repository at this point in the history
  • Loading branch information
vostrnad committed Nov 18, 2024
1 parent 711294d commit bc5a638
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/lib/SyntaxInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
let cursorPosition = 0
let shouldCheckForNewCurrentToken = false
let preventNewCurrentTokenCheck = false
let currentlyEditingToken: Token | undefined
let suggestedOpcodes: string[] = []
Expand Down Expand Up @@ -86,15 +87,19 @@
}
$: if (shouldCheckForNewCurrentToken) {
if (!preventNewCurrentTokenCheck) {
const token = tokenizedInput.findLast(
({ position }) => position < cursorPosition,
)
if (token !== currentlyEditingToken) {
currentlyEditingToken = token
}
}
// eslint-disable-next-line no-useless-assignment
shouldCheckForNewCurrentToken = false
const token = tokenizedInput.findLast(
({ position }) => position < cursorPosition,
)
if (token !== currentlyEditingToken) {
currentlyEditingToken = token
}
// eslint-disable-next-line no-useless-assignment
preventNewCurrentTokenCheck = false
}
export let width = 0
Expand Down Expand Up @@ -252,6 +257,9 @@
suggestedOpcodes = []
}
}}
on:paste={() => {
preventNewCurrentTokenCheck = true
}}
on:input={() => {
cursorPosition = textareaElement.selectionStart
shouldCheckForNewCurrentToken = true
Expand Down

0 comments on commit bc5a638

Please sign in to comment.