diff options
author | teicher | 2009-03-05 23:57:05 +0000 |
---|---|---|
committer | teicher | 2009-03-05 23:57:05 +0000 |
commit | cb9a701230d615deedd8f788dfe806f69cbf9f85 (patch) | |
tree | df8c75283e624a8e9bc67a8a2b5a7871e1dcccc4 /org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java | |
parent | c5c906d22b0fc7a3114a406040717606a4101217 (diff) | |
download | eclipse.platform.text-cb9a701230d615deedd8f788dfe806f69cbf9f85.tar.gz eclipse.platform.text-cb9a701230d615deedd8f788dfe806f69cbf9f85.tar.xz eclipse.platform.text-cb9a701230d615deedd8f788dfe806f69cbf9f85.zip |
bug 265267 [block selection][projection] Edits in folded regions have unexpected results
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java')
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java index 3f05cf76316..5231454a58b 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java @@ -124,6 +124,17 @@ public final class SelectionProcessor { IRegion[] getRanges(ISelection selection) throws BadLocationException { return new IRegion[0]; } + + /** + * Returns the number of lines touched by <code>selection</code>. + * + * @param selection the selection + * @return the number of lines touched by <code>selection</code> + * @throws BadLocationException if accessing the document failed + */ + int getCoveredLines(ISelection selection) throws BadLocationException { + return 0; + } } private final Implementation NULL_IMPLEMENTATION= new Implementation(); @@ -172,6 +183,11 @@ public final class SelectionProcessor { ITextSelection ts= (ITextSelection)selection; return new IRegion[] { new Region(ts.getOffset(), ts.getLength()) }; } + + int getCoveredLines(ISelection selection) throws BadLocationException { + ITextSelection ts= (ITextSelection)selection; + return ts.getEndLine() - ts.getStartLine() + 1; + } }; private final Implementation COLUMN_IMPLEMENTATION= new Implementation() { @@ -185,6 +201,7 @@ public final class SelectionProcessor { int endColumn= cts.getEndColumn(); int visualStartColumn= computeVisualColumn(startLine, startColumn); int visualEndColumn= computeVisualColumn(endLine, endColumn); + visualEndColumn= Math.max(visualStartColumn, visualEndColumn); // HACK - TextViewer::getSelection does not know about virtual selections root= new MultiTextEdit(); String[] delimiters= fDocument.getLegalLineDelimiters(); @@ -320,6 +337,11 @@ public final class SelectionProcessor { return ranges; } + + int getCoveredLines(ISelection selection) throws BadLocationException { + ITextSelection ts= (ITextSelection)selection; + return ts.getEndLine() - ts.getStartLine() + 1; + } private TextEdit createReplaceEdit(int line, int visualStartColumn, int visualEndColumn, String replacement) throws BadLocationException { IRegion info= fDocument.getLineInformation(line); @@ -573,6 +595,18 @@ public final class SelectionProcessor { } /** + * Returns the number of lines touched by <code>selection</code>. Note that for linear + * selections, this is the number of contained delimiters plus 1. + * + * @param selection the selection + * @return the number of lines touched by <code>selection</code> + * @throws BadLocationException if accessing the document failed + */ + public int getCoveredLines(ISelection selection) throws BadLocationException { + return getImplementation(selection).getCoveredLines(selection); + } + + /** * Returns the implementation. * * @param selection the selection |