languagesupport: check that ui.languagesupport is non-nil

Now that FileManager registers its UI modules in the same way as Reader,
this shouldn't be necessary but this protects us against some other app
creating a ReaderDictionary instance without having ui.languagesupport
registered properly.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai authored and poire-z committed 2021-10-26 07:41:17 +02:00
1 parent cdbedcbcce
commit de7c1e20c5
2 files changed
+3 -3

No files matched your search

@@ -864,7 +864,7 @@ function ReaderHighlight:onHold(arg, ges)
self.selected_link = link
end
if self.ui.languagesupport:hasActiveLanguagePlugins() then
if self.ui.languagesupport and self.ui.languagesupport:hasActiveLanguagePlugins() then
-- If this is a language where pan-less word selection needs some
-- extra work above and beyond what the document engine gives us
-- from getWordFromPosition, call the relevant language-specific
@@ -1338,7 +1338,7 @@ function ReaderHighlight:highlightFromHoldPos()
if self.hold_pos then
if not self.selected_text then
self.selected_text = self.ui.document:getTextFromPositions(self.hold_pos, self.hold_pos)
if self.ui.languagesupport:hasActiveLanguagePlugins() then
if self.ui.languagesupport and self.ui.languagesupport:hasActiveLanguagePlugins() then
-- Match language-specific expansion you'd get from self:onHold().
local new_selected_text = self.ui.languagesupport:improveWordSelection(self.selected_text)
if new_selected_text then