diff options
author | Bronwyn Damm | 2022-09-06 17:35:29 +0000 |
---|---|---|
committer | Bronwyn Damm | 2022-09-06 21:47:07 +0000 |
commit | 2ca96e0938a77020cdb49d863046f9dac4716bbe (patch) | |
tree | 19420a94c8bbd1fe2aa7a52f79ee232519f8845d | |
parent | 21252cb6352eb568f169b813910c25f1fc14d55f (diff) | |
download | org.eclipse.mylyn.docs-2ca96e0938a77020cdb49d863046f9dac4716bbe.tar.gz org.eclipse.mylyn.docs-2ca96e0938a77020cdb49d863046f9dac4716bbe.tar.xz org.eclipse.mylyn.docs-2ca96e0938a77020cdb49d863046f9dac4716bbe.zip |
580578: Return absolute offset in nested confluence delimited block
Offset of line was returning just the local offset and not the offset in
context of the rest of the line, this led to an infinite loop.
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=580578
Change-Id: Ic2b114be02714e2c62ffe00195d20ff7eb6e43b1
2 files changed, 67 insertions, 4 deletions
diff --git a/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/main/java/org/eclipse/mylyn/wikitext/confluence/internal/block/AbstractConfluenceDelimitedBlock.java b/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/main/java/org/eclipse/mylyn/wikitext/confluence/internal/block/AbstractConfluenceDelimitedBlock.java index b6cfbf1a6..363500bd9 100644 --- a/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/main/java/org/eclipse/mylyn/wikitext/confluence/internal/block/AbstractConfluenceDelimitedBlock.java +++ b/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/main/java/org/eclipse/mylyn/wikitext/confluence/internal/block/AbstractConfluenceDelimitedBlock.java @@ -69,12 +69,12 @@ public abstract class AbstractConfluenceDelimitedBlock extends ParameterizedBloc setClosed(true); } - return finalOffset(line.length(), endOfContent, contentOffset); + return finalOffset(line.length(), endOfContent, contentOffset, offset); } - private int finalOffset(int lineLength, int endOfContent, int contentOffset) { - int finalOffset = contentOffset; - if (contentOffset == lineLength) { + private int finalOffset(int lineLength, int endOfContent, int contentOffset, int initialOffset) { + int finalOffset = contentOffset == -1 ? -1 : initialOffset + contentOffset; + if (finalOffset == lineLength) { finalOffset = -1; } else if (endOfContent != lineLength) { finalOffset = endOfContent; diff --git a/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/test/java/org/eclipse/mylyn/wikitext/confluence/internal/block/ConfluenceNestedDelimitedBlockTest.java b/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/test/java/org/eclipse/mylyn/wikitext/confluence/internal/block/ConfluenceNestedDelimitedBlockTest.java new file mode 100644 index 000000000..2ee0f3c5f --- /dev/null +++ b/wikitext/core/org.eclipse.mylyn.wikitext.confluence/src/test/java/org/eclipse/mylyn/wikitext/confluence/internal/block/ConfluenceNestedDelimitedBlockTest.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 David Green and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Green - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.wikitext.confluence.internal.block; + +import org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage; +import org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest; +import org.junit.Test; + +public class ConfluenceNestedDelimitedBlockTest extends AbstractMarkupGenerationTest<ConfluenceLanguage> { + + @Override + protected ConfluenceLanguage createMarkupLanguage() { + return new ConfluenceLanguage(); + } + + @Test + public void quoteBlockContainingTable() { + assertMarkup( + "<blockquote><table><tr><th><strong>Column 1</strong></th><th><strong>Column 2</strong></th><th><strong>Column 3</strong></th></tr>" // + + "<tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr>" // + + "<tr><td>Cell 4</td><td>Cell 5</td><td>Cell 6</td></tr></table>" // + + "<p>Thank you</p></blockquote>", + "{quote}" + "||*Column 1*||*Column 2*||*Column 3*||\n" // + + "| Cell 1 | Cell 2| Cell 3|\n" // + + "| Cell 4| Cell 5| Cell 6|\n" // + + "\nThank you\n{quote}"); + } + + @Test + public void quoteBlockContainingTableContainingList() { + assertMarkup( + "<blockquote><table><tr><th><strong>Column 1</strong></th><th><strong>Column 2</strong></th><th><strong>Column 3</strong></th></tr>" // + + "<tr><td><ul><li>Bullet 1 </li></ul></td><td><ul><li>Bullet 2</li></ul></td><td><ul><li>Bullet 3</li></ul></td></tr>" // + + "<tr><td><ul><li>Bullet 4</li></ul></td><td><ul><li>Bullet 5</li></ul></td><td><ul><li>Bullet 6</li></ul></td></tr></table>" // + + "<p>Thank you</p></blockquote>", + "{quote}" + "||*Column 1*||*Column 2*||*Column 3*||\n" // + + "| * Bullet 1 | * Bullet 2| * Bullet 3|\n" // + + "| * Bullet 4| * Bullet 5| * Bullet 6|\n" // + + "\nThank you\n{quote}"); + } + + @Test + public void quoteBlockContainingTableContainingMultiLineList() { + assertMarkup("<blockquote><table><tr><th><strong>Column 1</strong></th><th><strong>Column 2</strong></th></tr>" // + + "<tr><td><ul><li>1.1</li><li>1.2<ul><li>1.2.1</li><li>1.2.2</li></ul></li></ul></td><td><ul><li>2.1</li><li>2.2</li><li>2.3</li></ul></td></tr>" // + + "<tr><td><ul><li>3.1</li></ul></td><td><ul><li>4.1</li><li>4.2</li><li>4.3</li><li>4.4</li></ul></td></tr></table>" // + + "<p>Thank you</p></blockquote>", + "{quote}" + "||*Column 1*||*Column 2*||\n" // + + "|* 1.1\n* 1.2\n** 1.2.1\n** 1.2.2" + "|* 2.1\n* 2.2\n* 2.3|\n" // + + "|* 3.1" + "|* 4.1\n* 4.2\n* 4.3\n* 4.4|\n" // + + "\nThank you\n{quote}"); + } + +} |