Skip to content

Commit

Permalink
fix: HunspellSpellchecker: multiple initializations
Browse files Browse the repository at this point in the history
Fix the case that User observed multiple HUNSPELL_CHECKER_INITIALIZED logs when user reloading project.

Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Mar 1, 2025
1 parent 6a1473d commit c73b9d9
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions src/org/omegat/core/spellchecker/AbstractSpellChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ public abstract class AbstractSpellChecker implements ISpellChecker {
private Path learnedFilePath;

public AbstractSpellChecker() {
CoreEvents.registerProjectChangeListener(eventType -> {
switch (eventType) {
case LOAD:
case CREATE:
initialize();
break;
case CLOSE:
destroy();
break;
default:
// Nothing
}
resetCache();
});
CoreEvents.registerEntryEventListener(new IEntryEventListener() {
public void onNewFile(String activeFileName) {
resetCache();
}

public void onEntryActivated(SourceTextEntry newEntry) {
}
});
}

/**
Expand All @@ -117,31 +139,8 @@ public boolean initialize() {
if (checker == null) {
LOGGER.atInfo().logRB("SPELLCHECKER_LANGUAGE_NOT_FOUND", targetLanguage);
return false;
} else {
loadWordLists();
CoreEvents.registerProjectChangeListener(eventType -> {
switch (eventType) {
case LOAD:
case CREATE:
initialize();
break;
case CLOSE:
destroy();
break;
default:
// Nothing
}
resetCache();
});
CoreEvents.registerEntryEventListener(new IEntryEventListener() {
public void onNewFile(String activeFileName) {
resetCache();
}

public void onEntryActivated(SourceTextEntry newEntry) {
}
});
}
loadWordLists();
return true;
}

Expand Down

0 comments on commit c73b9d9

Please sign in to comment.