ContentAssistant and partitioned documents [message #802269] |
Sun, 19 February 2012 18:04 |
Filippo Pacifici Messages: 1 Registered: February 2012 |
Junior Member |
|
|
Hello,
I am developing content assistant feature for a plugin:
I am using a SourceViewer, with an instance of Document attached.
The document is partitioned through an org.eclipse.jface.text.rules.FastPartitioner, and i am using an instance of org.eclipse.jface.text.contentassist.ContentAssistant.
As long as I try to use content assistant from any position in the document which is not the last character everything is fine:
-partitioning is correctly performed
-content assistant popup works fine
When I try, instead, to open content assistant popup on the last character of the document I don't manage to have the popup opened (no matter if I am in a crrect partition). More precisely what happens is:
1) ContentAssistant.computeCompletionProposals(ITextViewer, offset) is invoked (as usual), and the offset does not correspond to the offset of the last character of the document but at the position of the cursor (which is the offset of the last character + 1).
2) when fast partitioner is called to return the proper partition at that offset, it returns IDocument.DEFAULT_CONTENT_TYPE since the provided offset is out of the last partition of the document (which terminates at the last character of the document).
Here is the code snippet from FastPartitioner:
public ITypedRegion getPartition(int offset) {
....
TypedPosition previous= (TypedPosition) category[category.length - 1];
if (previous.includes(offset))
return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
int endOffset= previous.getOffset() + previous.getLength();
return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
previous.include(offset) returns since the last valid offset is the one of the last character in the document.
Do you think it is a bug in ContentAssistant? or am I missing something?
Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.02258 seconds