some cases where lookup was not under the prefix fixed

This commit is contained in:
peter.gromov
2010-10-21 19:42:31 +04:00
parent a3a06b1bce
commit 90b6ca94e2
2 changed files with 4 additions and 11 deletions
@@ -38,15 +38,6 @@ public class BackspaceHandler extends EditorActionHandler {
return;
}
boolean toRestart = false;
final String prefix = lookup.getAdditionalPrefix();
if (prefix.length() > 0) {
lookup.setAdditionalPrefix(prefix.substring(0, prefix.length() - 1));
}
else {
toRestart = lookup.getLookupStart() < editor.getCaretModel().getOffset();
}
lookup.performGuardedChange(new Runnable() {
@Override
public void run() {
@@ -54,11 +45,13 @@ public class BackspaceHandler extends EditorActionHandler {
}
});
final String prefix = lookup.getAdditionalPrefix();
if (prefix.length() > 0) {
lookup.setAdditionalPrefix(prefix.substring(0, prefix.length() - 1));
return;
}
if (toRestart) {
if (lookup.getLookupStart() < editor.getCaretModel().getOffset()) {
final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion();
if (process instanceof CompletionProgressIndicator) {
((CompletionProgressIndicator)process).restartCompletion();
@@ -58,7 +58,6 @@ public class TypedHandler implements TypedActionHandler {
}
});
if (result == CharFilter.Result.ADD_TO_PREFIX) {
lookup.setAdditionalPrefix(lookup.getAdditionalPrefix() + charTyped);
Document document = editor.getDocument();
long modificationStamp = document.getModificationStamp();
@@ -67,6 +66,7 @@ public class TypedHandler implements TypedActionHandler {
EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, String.valueOf(charTyped), true);
}
});
lookup.setAdditionalPrefix(lookup.getAdditionalPrefix() + charTyped);
AutoHardWrapHandler.getInstance().wrapLineIfNecessary(editor, dataContext, modificationStamp);