Skip to content

Commit

Permalink
fix the situation with emphasis editing (aaaa:1.1) bbbb (cccc:1.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Oct 21, 2023
1 parent 384fab9 commit 464fbcd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions javascript/edit-attention.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ function keyupEditAttention(event) {
let beforeParen = before.lastIndexOf(OPEN);
if (beforeParen == -1) return false;

let beforeClosingParen = before.lastIndexOf(CLOSE);
if (beforeClosingParen != -1 && beforeClosingParen > beforeParen) return false;

// Find closing parenthesis around current cursor
const after = text.substring(selectionStart);
let afterParen = after.indexOf(CLOSE);
if (afterParen == -1) return false;

let afterOpeningParen = after.indexOf(OPEN);
if (afterOpeningParen != -1 && afterOpeningParen < beforeParen) return false;

// Set the selection to the text between the parenthesis
const parenContent = text.substring(beforeParen + 1, selectionStart + afterParen);
if (/.*:-?[\d.]+/s.test(parenContent)) {
Expand Down

0 comments on commit 464fbcd

Please sign in to comment.