Skip to content

Commit 9fc04d6

Browse files
authored
Use "python" for markdown code fences in on-hover content (#19082)
Instead of "text". Closes astral-sh/ty#749 We may not want this because the type display implementations are not guaranteed to be valid Python, however, unless they're going to highlight invalid syntax this seems like a better interim value than "text"? I'm not the expert though. See astral-sh/ty#749 (comment) for prior commentary. edit: Going back further to #17057 (comment) for prior context, it turns out they _do_ highlight invalid syntax in red which is quite unfortunate and probably a blocker here.
1 parent 352b896 commit 9fc04d6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

crates/ty_ide/src/hover.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl fmt::Display for DisplayHoverContent<'_, '_> {
118118
match self.content {
119119
HoverContent::Type(ty) => self
120120
.kind
121-
.fenced_code_block(ty.display(self.db), "text")
121+
.fenced_code_block(ty.display(self.db), "python")
122122
.fmt(f),
123123
}
124124
}
@@ -148,7 +148,7 @@ mod tests {
148148
assert_snapshot!(test.hover(), @r"
149149
Literal[10]
150150
---------------------------------------------
151-
```text
151+
```python
152152
Literal[10]
153153
```
154154
---------------------------------------------
@@ -184,7 +184,7 @@ mod tests {
184184
assert_snapshot!(test.hover(), @r"
185185
int
186186
---------------------------------------------
187-
```text
187+
```python
188188
int
189189
```
190190
---------------------------------------------
@@ -214,7 +214,7 @@ mod tests {
214214
assert_snapshot!(test.hover(), @r"
215215
def foo(a, b) -> Unknown
216216
---------------------------------------------
217-
```text
217+
```python
218218
def foo(a, b) -> Unknown
219219
```
220220
---------------------------------------------
@@ -243,7 +243,7 @@ mod tests {
243243
assert_snapshot!(test.hover(), @r"
244244
bool
245245
---------------------------------------------
246-
```text
246+
```python
247247
bool
248248
```
249249
---------------------------------------------
@@ -274,7 +274,7 @@ mod tests {
274274
assert_snapshot!(test.hover(), @r"
275275
Literal[123]
276276
---------------------------------------------
277-
```text
277+
```python
278278
Literal[123]
279279
```
280280
---------------------------------------------
@@ -312,7 +312,7 @@ mod tests {
312312
assert_snapshot!(test.hover(), @r"
313313
(def foo(a, b) -> Unknown) | (def bar(a, b) -> Unknown)
314314
---------------------------------------------
315-
```text
315+
```python
316316
(def foo(a, b) -> Unknown) | (def bar(a, b) -> Unknown)
317317
```
318318
---------------------------------------------
@@ -344,7 +344,7 @@ mod tests {
344344
assert_snapshot!(test.hover(), @r"
345345
<module 'lib'>
346346
---------------------------------------------
347-
```text
347+
```python
348348
<module 'lib'>
349349
```
350350
---------------------------------------------
@@ -373,7 +373,7 @@ mod tests {
373373
assert_snapshot!(test.hover(), @r"
374374
T
375375
---------------------------------------------
376-
```text
376+
```python
377377
T
378378
```
379379
---------------------------------------------
@@ -399,7 +399,7 @@ mod tests {
399399
assert_snapshot!(test.hover(), @r"
400400
@Todo
401401
---------------------------------------------
402-
```text
402+
```python
403403
@Todo
404404
```
405405
---------------------------------------------
@@ -425,7 +425,7 @@ mod tests {
425425
assert_snapshot!(test.hover(), @r"
426426
@Todo
427427
---------------------------------------------
428-
```text
428+
```python
429429
@Todo
430430
```
431431
---------------------------------------------
@@ -451,7 +451,7 @@ mod tests {
451451
assert_snapshot!(test.hover(), @r"
452452
Literal[1]
453453
---------------------------------------------
454-
```text
454+
```python
455455
Literal[1]
456456
```
457457
---------------------------------------------
@@ -482,7 +482,7 @@ mod tests {
482482
assert_snapshot!(test.hover(), @r"
483483
Literal[1]
484484
---------------------------------------------
485-
```text
485+
```python
486486
Literal[1]
487487
```
488488
---------------------------------------------
@@ -512,7 +512,7 @@ mod tests {
512512
assert_snapshot!(test.hover(), @r"
513513
Literal[2]
514514
---------------------------------------------
515-
```text
515+
```python
516516
Literal[2]
517517
```
518518
---------------------------------------------
@@ -545,7 +545,7 @@ mod tests {
545545
assert_snapshot!(test.hover(), @r"
546546
Unknown | Literal[1]
547547
---------------------------------------------
548-
```text
548+
```python
549549
Unknown | Literal[1]
550550
```
551551
---------------------------------------------
@@ -574,7 +574,7 @@ mod tests {
574574
assert_snapshot!(test.hover(), @r"
575575
int
576576
---------------------------------------------
577-
```text
577+
```python
578578
int
579579
```
580580
---------------------------------------------
@@ -602,7 +602,7 @@ mod tests {
602602
assert_snapshot!(test.hover(), @r"
603603
Literal[1]
604604
---------------------------------------------
605-
```text
605+
```python
606606
Literal[1]
607607
```
608608
---------------------------------------------
@@ -631,7 +631,7 @@ mod tests {
631631
assert_snapshot!(test.hover(), @r"
632632
int
633633
---------------------------------------------
634-
```text
634+
```python
635635
int
636636
```
637637
---------------------------------------------
@@ -661,7 +661,7 @@ mod tests {
661661
assert_snapshot!(test.hover(), @r"
662662
str
663663
---------------------------------------------
664-
```text
664+
```python
665665
str
666666
```
667667
---------------------------------------------

0 commit comments

Comments
 (0)