mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 16:28:56 +00:00
Merge pull request #1645 from loradd/loradd/fix-findings-from-conversion-1517
Fixes eclipse/xtext-core#1517
This commit is contained in:
commit
610ea8dfa4
1 changed files with 8 additions and 13 deletions
|
@ -183,19 +183,14 @@ public class ContentAssistService {
|
|||
}
|
||||
|
||||
protected TextEdit toTextEdit(ReplaceRegion region, Document doc) {
|
||||
Position start = null;
|
||||
if (region.getOffset() > doc.getContents().length()) {
|
||||
Position docEnd = doc.getPosition(doc.getContents().length());
|
||||
start = new Position(docEnd.getLine(), docEnd.getCharacter() + region.getLength());
|
||||
} else {
|
||||
start = doc.getPosition(region.getOffset());
|
||||
}
|
||||
Position end = null;
|
||||
if (region.getEndOffset() > doc.getContents().length()) {
|
||||
end = new Position(start.getLine(), start.getCharacter() + region.getLength());
|
||||
} else {
|
||||
end = doc.getPosition(region.getEndOffset());
|
||||
}
|
||||
final Position start = getPosition(doc, region.getOffset());
|
||||
final Position end = getPosition(doc, region.getEndOffset());
|
||||
return new TextEdit(new Range(start, end), region.getText());
|
||||
}
|
||||
|
||||
private Position getPosition(final Document doc, final int offset) {
|
||||
final int docLength = doc.getContents().length();
|
||||
return offset > docLength ? doc.getPosition(docLength) : doc.getPosition(offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue