Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 11 additions & 9 deletions desktop/src/features/messages/lib/mentionHighlightExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,7 @@ export function buildHighlightPatterns(
n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
);
patterns.push(
new RegExp(
`(?:^|(?<=[\\s(]))@(${escapedNames.join("|")})(?=\\W|$)`,
"gi",
),
new RegExp(`(^|[\\s(])@(${escapedNames.join("|")})(?=\\W|$)`, "gi"),
);
}

Expand All @@ -580,10 +577,7 @@ export function buildHighlightPatterns(
n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
);
patterns.push(
new RegExp(
`(?:^|(?<=\\s))#(${escapedChannels.join("|")})(?=\\W|$)`,
"gi",
),
new RegExp(`(^|\\s)#(${escapedChannels.join("|")})(?=\\W|$)`, "gi"),
);
}

Expand Down Expand Up @@ -671,7 +665,15 @@ export function findHighlightMatches(
pattern.lastIndex = 0;
let m: RegExpExecArray | null = pattern.exec(text);
while (m !== null) {
results.push({ from: m.index, to: m.index + m[0].length, match: m[0] });
// Group 1 is the boundary prefix (empty at start-of-text). It replaces
// the previous lookbehind, which macOS 12's WebKit cannot parse
// (see block/buzz#3295); skip it so offsets point at the @/# sigil.
const prefixLen = m[1] ? m[1].length : 0;
results.push({
from: m.index + prefixLen,
to: m.index + m[0].length,
match: m[0].slice(prefixLen),
});
m = pattern.exec(text);
}
}
Expand Down
29 changes: 26 additions & 3 deletions desktop/src/features/settings/ui/KeyboardShortcutsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,34 @@ import {
} from "./SettingsOptionGroup";
import { SettingsSectionHeader } from "./SettingsSectionHeader";

// Split a key-combo string on "+" separators. A "+" is a separator unless it
// directly follows another "+" (so "⌘++" keeps "+" as a key) or only
// whitespace remains after it (so a trailing "+" stays attached). Mirrors the
// previous /(?<!\+)\+(?!\s*$)/ split without lookbehind/lookahead.
function splitKeyCombo(keys: string): string[] {
const parts: string[] = [];
let current = "";
for (let i = 0; i < keys.length; i++) {
const ch = keys[i];
const isSeparator =
ch === "+" && keys[i - 1] !== "+" && keys.slice(i + 1).trim() !== "";
if (isSeparator) {
parts.push(current);
current = "";
} else {
current += ch;
}
}
parts.push(current);
return parts;
}

function KeyCombo({ shortcut }: { shortcut: KeyboardShortcut }) {
const keys = getPlatformKeys(shortcut);
// Split on "+" but keep "+" as a standalone key (e.g. for zoom-in "⌘+")
const parts = keys
.split(/(?<!\+)\+(?!\s*$)/)
// Split on "+" but keep "+" as a standalone key (e.g. for zoom-in "⌘+").
// Implemented without RegExp lookbehind so the bundle parses on macOS 12's
// system WebKit (Safari 16.4 feature). See block/buzz#3295.
const parts = splitKeyCombo(keys)
.map((p) => p.trim())
.filter(Boolean);

Expand Down
7 changes: 7 additions & 0 deletions desktop/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export default defineConfig(async ({ mode }) => {
},
},

// Target Safari 15 so the bundle parses on macOS 12's system WebKit (613),
// which lacks Safari 16.4 syntax (e.g. RegExp lookbehind in literals,
// class static blocks). See https://github.com/block/buzz/issues/3295
build: {
target: ["es2020", "safari15"],
},

// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
Expand Down
13 changes: 13 additions & 0 deletions patches/mdast-util-gfm-autolink-literal@2.0.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/index.js b/lib/index.js
index c5ca771c24dd914e342f791716a822431ee32b3a..7fcfaf8441a81d42cceb059c7f48925373e794d3 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -132,7 +132,7 @@ function transformGfmAutolinkLiterals(tree) {
tree,
[
[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
- [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
+ [/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
],
{ignore: ['link', 'linkReference']}
)
5 changes: 3 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ overrides:
linkify-it: "^5.0.2"
patchedDependencies:
isomorphic-git: patches/isomorphic-git.patch
mdast-util-gfm-autolink-literal@2.0.1: patches/mdast-util-gfm-autolink-literal@2.0.1.patch
virtua@0.49.3: patches/virtua@0.49.3.patch