1
0
mirror of https://github.com/elisspace/ObsidianTweaks.git synced 2026-08-29 15:44:02 +00:00

fix: word extension detection sometimes bad

This commit is contained in:
Jeppe Klitgaard
2021-06-13 21:47:26 +01:00
parent fea6b66f83
commit 83df90553f
5 changed files with 14 additions and 6 deletions

View File

@@ -54,7 +54,7 @@ Move selection does not support going across lines. This seems unnecessary and
is really messy to implement.
### Better Toggles
The default toggles in Obsidian can be quite wonky and do not always
The default toggles in Obsidian can be a bit wonky at times and do not always
work well. The toggles implemented here should always return to the
same state when toggled twice.

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-tweaks",
"name": "Obsidian Tweaks",
"version": "0.2.1",
"version": "0.2.2",
"minAppVersion": "0.12.3",
"description": "A small plugin that implements some sorely missed features.",
"author": "Jeppe Klitgaard",

View File

@@ -1,6 +1,6 @@
{
"name": "obsidian-tweaks",
"version": "0.2.1",
"version": "0.2.2",
"description": "A small plugin that implements some sorely missed features.",
"main": "main.js",
"scripts": {

View File

@@ -74,9 +74,16 @@ export class BetterFormatting {
{line: wordEnd.line, ch: wordEnd.ch + symbolEnd.length},
)
if (preWordStart === symbolStart && postWordStart === symbolEnd) {
wordStart = {line: wordStart.line, ch: wordStart.ch - symbolStart.length}
wordEnd = {line: wordEnd.line, ch: wordEnd.ch + symbolEnd.length}
if (
(preWordStart === symbolStart || textToWrap.startsWith(symbolStart)) &&
(postWordStart === symbolEnd || textToWrap.endsWith(symbolEnd))
) {
// Calculate which offsets to use depending on which of the cases above
let startOffset = textToWrap.startsWith(symbolStart) ? 0 : -2
let endOffset = textToWrap.endsWith(symbolEnd) ? 0 : 2
wordStart = {line: wordStart.line, ch: wordStart.ch + startOffset}
wordEnd = {line: wordEnd.line, ch: wordEnd.ch + endOffset}
// Update textToWrap
textToWrap = editor.getRange(wordStart, wordEnd)

View File

@@ -1,4 +1,5 @@
{
"0.2.2": "0.12.3",
"0.2.1": "0.12.3",
"0.2.0": "0.12.3",
"0.1.1": "0.12.3",