Account for markdown styling in mentions offset calculation.

This also means that we can support smart punctuation.

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Piotr Osiewicz
2023-10-23 12:50:57 +02:00
co-authored by Max
parent 763b13e700
commit 812ff9a97d
7 changed files with 207 additions and 96 deletions
+17 -28
View File
@@ -1,6 +1,6 @@
import { background, border, text } from "./components"
import { background, border, foreground, text } from "./components"
import { icon_button } from "../component/icon_button"
import { useTheme } from "../theme"
import { useTheme, with_opacity } from "../theme"
import { interactive } from "../element"
import { Color } from "ayu/dist/color"
@@ -86,8 +86,21 @@ export default function chat_panel(): any {
top: 4,
},
},
mention_highlight: { weight: "bold" },
self_mention_background: background(layer, "active"),
rich_text: {
text: text(layer, "sans", "base"),
code_background: with_opacity(foreground(layer, "accent"), 0.1),
mention_highlight: { weight: "bold" },
self_mention_highlight: { weight: "bold" },
self_mention_background: background(layer, "active"),
},
message_sender: {
margin: {
right: 8,
},
...text(layer, "sans", "base", { weight: "bold" }),
},
message_timestamp: text(layer, "sans", "base", "disabled"),
message: {
...interactive({
base: {
@@ -105,25 +118,9 @@ export default function chat_panel(): any {
},
},
}),
body: text(layer, "sans", "base"),
sender: {
margin: {
right: 8,
},
...text(layer, "sans", "base", { weight: "bold" }),
},
timestamp: text(layer, "sans", "base", "disabled"),
},
last_message_bottom_spacing: SPACING,
continuation_message: {
body: text(layer, "sans", "base"),
sender: {
margin: {
right: 8,
},
...text(layer, "sans", "base", { weight: "bold" }),
},
timestamp: text(layer, "sans", "base", "disabled"),
...interactive({
base: {
padding: {
@@ -141,14 +138,6 @@ export default function chat_panel(): any {
}),
},
pending_message: {
body: text(layer, "sans", "base"),
sender: {
margin: {
right: 8,
},
...text(layer, "sans", "base", "disabled"),
},
timestamp: text(layer, "sans", "base"),
...interactive({
base: {
padding: {