Skip to content

Commit ef3455d

Browse files
author
TfT Hacker
committed
2.3.1 Smarter link references
1 parent 2d8eadd commit ef3455d

File tree

7 files changed

+17
-5
lines changed

7 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# # 2.3.1
2+
- Change: if a link is the only link in the vault to a destination (thus the reference count is 1), the reference counter will not be shown next to the link, regardless of the minimum threshold count set in settings. This makes sense. If the link is used once, its obvious without the counter, and the counter simply stating the link has one reference was redudant and annoying to many users.
3+
14
# 2.3.0
25
- New: Added support for references to show up in the kanban plugin. This can be toggled on and off in settings.
36
- Changed: SNW's internal index did not include file extensions, which in some cases led to issues. the index now uses the full path with the extension, which means every file whether it is a MD file or not is included in the index.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian42-strange-new-worlds",
33
"name": "Strange New Worlds",
4-
"version": "2.3.0",
4+
"version": "2.3.1",
55
"minAppVersion": "1.7.2",
66
"description": "Help see how your vault is interconnected with visual indicators.",
77
"author": "TfTHacker",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian42-strange-new-worlds",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "Revealing networked thought and the strange new worlds created by your vault",
55
"scripts": {
66
"dev": "node --no-warnings esbuild.config.mjs",

src/view-extensions/gutters-cm6.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ const ReferenceGutterExtension = gutter({
7070
for (const embed of embedsFromMetaDataCache) {
7171
if (embed.position.start.line + 1 === lineNumberInFile) {
7272
for (const ref of transformedCache?.embeds ?? []) {
73-
if (ref?.references.length >= plugin.settings.minimumRefCountThreshold && ref?.pos.start.line + 1 === lineNumberInFile) {
73+
if (
74+
ref?.references.length >= Math.max(2, plugin.settings.minimumRefCountThreshold) &&
75+
ref?.pos.start.line + 1 === lineNumberInFile
76+
) {
7477
const lineToAnalyze = editorView.state.doc.lineAt(line.from).text.trim();
7578
if (lineToAnalyze.startsWith("!")) {
7679
// Remove [[ and ]] and split by | to get the link text if aliased

src/view-extensions/references-cm6.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ const constructWidgetForInlineReference = (
213213
modifyKey = modifyKey.replace(/^\s+|\s+$/g, ""); // should be not leading spaces
214214
}
215215

216+
if (refType === "link" && ref.references.length === 1) continue; // if this is a link and there is only one reference, don't show the widget
217+
216218
if (refType === "embed" || refType === "link") {
217219
// check for aliased references
218220
if (modifyKey.contains("|")) modifyKey = modifyKey.substring(0, key.search(/\|/));

src/view-extensions/references-preview.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ class snwChildComponentForMarkdownFile extends MarkdownRenderChild {
179179
) || dataHref;
180180

181181
for (const value of transformedCache.links ?? []) {
182-
if (value.references.length >= minRefCountThreshold && value.key.toLocaleUpperCase() === link.toLocaleUpperCase()) {
182+
if (
183+
value.references.length >= Math.max(2, minRefCountThreshold) &&
184+
value.key.toLocaleUpperCase() === link.toLocaleUpperCase()
185+
) {
183186
const referenceElement = htmlDecorationForReferencesElement(
184187
value.references.length,
185188
"link",

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"2.1.5": "1.7.2",
1414
"2.2.0": "1.7.2",
1515
"2.2.1": "1.7.2",
16-
"2.3.0": "1.7.2"
16+
"2.3.0": "1.7.2",
17+
"2.3.1": "1.7.2"
1718
}

0 commit comments

Comments
 (0)