Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Src/xWorks/XhtmlDocView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,11 @@ private void FindNextInBrowser(object sender, IBasicFindView view)

private void ScrollAndHighlightResult(GeckoWebBrowser geckoBrowser, IBasicFindView view, string lastId)
{
if (geckoBrowser.Document == null)
{
view.StatusText = "No Document";
return;
}
if (results != null && results.Length > 0)
{
view.StatusText = $"{resultIndex + 1} of {results.Length} Results";
Expand All @@ -1304,7 +1309,7 @@ private void ScrollAndHighlightResult(GeckoWebBrowser geckoBrowser, IBasicFindVi

private void ClearCurrentFindResult(GeckoWebBrowser geckoBrowser, string lastId)
{
var currentElement = geckoBrowser.Document.GetHtmlElementById(lastId);
var currentElement = geckoBrowser.Document?.GetHtmlElementById(lastId);
if (currentElement != null)
docView.RemoveClassFromHtmlElement(currentElement, CurrentSelectedEntryClass);
}
Expand All @@ -1317,6 +1322,12 @@ private bool InitResults(string searchText)
if (results == null || results.Length == 0)
{
string newResults = string.Empty;
if (geckoBrowser.Document == null)
{
results = newResults.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
resultIndex = 0;
return true;
}
geckoBrowser.RemoveMessageEventListener("find");
geckoBrowser.AddMessageEventListener("find", r => newResults = r);
using(var executor = new AutoJSContext(geckoBrowser.Window))
Expand Down
Loading