Skip to content

Commit

Permalink
Merge pull request #80 from erichalldev:master
Browse files Browse the repository at this point in the history
Fix reference counter appearing in wrong spot in reading mode
  • Loading branch information
TfTHacker authored Feb 28, 2023
2 parents 83e65ac + 9bd52b8 commit ba88db3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/view-extensions/references-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,23 @@ class snwChildComponent extends MarkdownRenderChild {
} catch (error) { /* nothing to do here */ }

for (const value of transformedCache.blocks) {
if ( value.references[0]?.excludedFile!=true && value.references.length >= minRefCountThreshold &&
(value.pos.start.line >= this.sectionInfo?.lineStart && value.pos.end.line <= this.sectionInfo?.lineEnd) &&
!isThisAnEmbed ) {
if (value.references[0]?.excludedFile != true
&& value.references.length >= minRefCountThreshold
&& (value.pos.start.line >= this.sectionInfo?.lineStart && value.pos.end.line <= this.sectionInfo?.lineEnd)
&& !isThisAnEmbed ) {
const referenceElement = htmlDecorationForReferencesElement(value.references.length, "block", value.key, value.references[0]?.resolvedFile?.path.replace(".md",""), "", value.pos.start.line);
let blockElement: HTMLElement = this.containerEl.querySelector('p')
let blockElement: HTMLElement = this.containerEl.querySelector('p');
const valueLineInSection: number = value.pos.start.line - this.sectionInfo.lineStart;
if (!blockElement) {
blockElement = this.containerEl.querySelector("li");
blockElement = this.containerEl.querySelector(`li[data-line="${valueLineInSection}"]`);
}
if (!blockElement) {
blockElement = this.containerEl.querySelector(`ol[data-line="${valueLineInSection}"]`)
}
try {
if (!blockElement.hasClass("snw-block-preview")) {
referenceElement.addClass("snw-block-preview");
blockElement.append(referenceElement);
break;
}
} catch (error) { /* nothing to do here */ }
}
Expand Down

0 comments on commit ba88db3

Please sign in to comment.