mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 12:51:35 +02:00
[cm6] fix toggling ranges next to command (#14183)
GitOrigin-RevId: 4959419a09415b202dc7ce2271e9691d2c2387d4
This commit is contained in:
committed by
Copybot
parent
f71ddaed92
commit
b674b08ace
@@ -467,7 +467,15 @@ export function toggleRanges(
|
||||
range.to === view.state.doc.length ? -1 : 1
|
||||
)
|
||||
|
||||
if (ancestorAtStartOfRange !== ancestorAtEndOfRange) {
|
||||
const tree = ensureSyntaxTree(view.state, 1000)
|
||||
const nodeAtFrom = tree?.resolveInner(range.from, 1)
|
||||
const nodeAtTo = tree?.resolveInner(range.to, -1)
|
||||
const isSingleNodeSelected = nodeAtFrom === nodeAtTo
|
||||
|
||||
if (
|
||||
!isSingleNodeSelected &&
|
||||
ancestorAtStartOfRange !== ancestorAtEndOfRange
|
||||
) {
|
||||
// But handle the exception of case 8
|
||||
const ancestorAtStartIsWrappingCommand =
|
||||
ancestorAtStartOfRange &&
|
||||
|
||||
@@ -196,4 +196,28 @@ describe('toggleRanges', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('still formats text next to a command', function () {
|
||||
const cm = new CodemirrorTestSession(['<item>\\foo'])
|
||||
cm.applyCommand(BOLD_COMMAND)
|
||||
expect(cm).line(1).to.equal('\\textbf{item}\\foo')
|
||||
})
|
||||
|
||||
it('still formats part of a text next to command', function () {
|
||||
const cm = new CodemirrorTestSession(['hello <world>\\foo'])
|
||||
cm.applyCommand(BOLD_COMMAND)
|
||||
expect(cm).line(1).to.equal('hello \\textbf{world}\\foo')
|
||||
})
|
||||
|
||||
it('still formats command without arguments', function () {
|
||||
const cm = new CodemirrorTestSession(['\\item<\\foo>'])
|
||||
cm.applyCommand(BOLD_COMMAND)
|
||||
expect(cm).line(1).to.equal('\\item\\textbf{<\\foo>}')
|
||||
})
|
||||
|
||||
it('skips formatting if in the middle of two commands', function () {
|
||||
const cm = new CodemirrorTestSession(['\\f<oo\\b>ar'])
|
||||
cm.applyCommand(BOLD_COMMAND)
|
||||
expect(cm).line(1).to.equal('\\foo\\bar')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user