mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
Merge "[new CA] gracefully handle invalid selections"
This commit is contained in:
commit
e77154d709
1 changed files with 5 additions and 2 deletions
|
@ -468,11 +468,14 @@ public class ContentAssistContextFactory implements Function<ContentAssistContex
|
|||
context.setOffset(completionOffset);
|
||||
context.setPrefix(prefix);
|
||||
int regionLength = prefix.length();
|
||||
if (selection.getLength() > 0)
|
||||
if (selection.getLength() > 0) {
|
||||
regionLength = regionLength + selection.getLength();
|
||||
}
|
||||
ITextRegion region = new TextRegion(completionOffset - prefix.length(), regionLength);
|
||||
if (selection.getOffset() >= 0 && selection.getLength() >= 0) {
|
||||
context.setSelectedText(document.substring(selection.getOffset(), selection.getOffset() + selection.getLength()));
|
||||
}
|
||||
context.setReplaceRegion(region);
|
||||
context.setSelectedText(document.substring(selection.getOffset(), selection.getOffset() + selection.getLength()));
|
||||
context.setResource(resource);
|
||||
return context;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue