We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
LSP-rust-analyzer inlay hints appear on multiple lines
**Describe the bug**
inlay hints in `LSP-rust-analyzer` appear on multiple lines since https://github.com/rust-lang/rust-analyzer/pull/13699

**To Reproduce**
Steps to reproduce the behavior:

1. use the rust source file:

```rs
fn main() {
	let v = vec![
		"1".to_string(),
		"1".to_string(),
		"1".to_string(),
		"1".to_string(),
		"1".to_string(),
	];
	dbg!(&v);
}
```

2. settings files:

```js
// User/LSP.sublime-settings
// Settings in here override those in "LSP/LSP.sublime-settings"
{
	"show_inlay_hints": true,
}
```

```js
// User/LSP-rust-analyzer.sublime-settings
// Settings in here override those in "LSP-rust-analyzer/LSP-rust-analyzer.sublime-settings"
{
	"command": ["rust-analyzer-2022-12-26"],
	"settings": {
		// default: true
		"rust-analyzer.inlayHints.locationLinks": true,
	},
}

```

3. see the inlay hints broken down in multiple lines

![](https://user-images.githubusercontent.com/1024798/209812702-f2a89cf0-175d-493c-bb85-d31a20b42bf6.png)

**Expected behavior**

the inlay hints should be on one line

![](https://user-images.githubusercontent.com/1024798/209812987-03d51c4e-a601-47f6-8d97-b4e3841354ec.png)

**Environment (please complete the following information):**
- OS: Debian 11.6
- Sublime Text version: 4143
- LSP version: v1.20.0
- Language servers used: LSP-rust-analyzer v1.1.0

```
> rust-analyzer-2022-12-26 --version
rust-analyzer 0.3.1334-standalone
```

**Additional context**

the `"rust-analyzer.inlayHints.locationLinks": false` setting (default: `true`) makes them appear again on one line

LSP panel output:

**rust-analyzer-2022-12-19**

```py
:: --> rust-analyzer textDocument/inlayHint(19): {'textDocument': {'uri': 'file:///home/it/Desktop/asd/src/main.rs'}, 'range': {'end': {'character': 0, 'line': 10}, 'start': {'character': 0, 'line': 0}}}
:: <<< rust-analyzer 19: [
    {
        'kind': 1,
        'tooltip': ': Vec<String>',
        'paddingRight': False,
        'label': ': Vec<String>',
        'paddingLeft': False,
        'position': {'character': 6, 'line': 1},
        'data': {
            'text_document': {'uri': 'file:///home/it/Desktop/asd/src/main.rs', 'version': 24},
            'position': {'end': {'character': 6, 'line': 1}, 'start': {'character': 5, 'line': 1}},
        },
    }
]
```

**rust-analyzer-2022-12-26**

```py
:: --> rust-analyzer textDocument/inlayHint(40): {'textDocument': {'uri': 'file:///home/it/Desktop/asd/src/main.rs'}, 'range': {'end': {'character': 0, 'line': 11}, 'start': {'character': 0, 'line': 0}}}
:: <<< rust-analyzer 40: [
    {
        'kind': 1,
        'tooltip': ': Vec<String>',
        'paddingRight': False,
        'label': [
            {'value': ': '},
            {
                'value': 'Vec',
                'location': {
                    'uri': 'file:///home/it/.local/lib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs',
                    'range': {'end': {'character': 14, 'line': 399}, 'start': {'character': 11, 'line': 399}},
                },
            },
            {'value': '<'},
            {
                'value': 'String',
                'location': {
                    'uri': 'file:///home/it/.local/lib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/string.rs',
                    'range': {'end': {'character': 17, 'line': 366}, 'start': {'character': 11, 'line': 366}},
                },
            },
            {'value': '>'},
        ],
        'paddingLeft': False,
        'position': {'character': 6, 'line': 1},
        'data': {
            'text_document': {'uri': 'file:///home/it/Desktop/asd/src/main.rs', 'version': 8},
            'position': {'end': {'character': 6, 'line': 1}, 'start': {'character': 5, 'line': 1}},
        },
    }
]
```




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `plugin/inlay_hint.py`
Content:
```
1 from .core.protocol import InlayHintLabelPart, MarkupContent, Point, InlayHint, Request
2 from .core.registry import LspTextCommand
3 from .core.sessions import Session
4 from .core.typing import Optional, Union
5 from .core.views import point_to_offset
6 from .formatting import apply_text_edits_to_view
7 import html
8 import sublime
9 import uuid
10 
11 
12 class LspInlayHintClickCommand(LspTextCommand):
13     capability = 'inlayHintProvider'
14 
15     def run(self, _edit: sublime.Edit, session_name: str, inlay_hint: InlayHint, phantom_uuid: str,
16             event: Optional[dict] = None, label_part: Optional[InlayHintLabelPart] = None) -> None:
17         # Insert textEdits for the given inlay hint.
18         # If a InlayHintLabelPart was clicked, label_part will be passed as an argument to the LspInlayHintClickCommand
19         # and InlayHintLabelPart.command will be executed.
20         session = self.session_by_name(session_name, 'inlayHintProvider')
21         if session and session.has_capability('inlayHintProvider.resolveProvider'):
22             request = Request.resolveInlayHint(inlay_hint, self.view)
23             session.send_request_async(
24                 request,
25                 lambda response: self.handle(session_name, response, phantom_uuid, label_part))
26             return
27         self.handle(session_name, inlay_hint, phantom_uuid, label_part)
28 
29     def handle(self, session_name: str, inlay_hint: InlayHint, phantom_uuid: str,
30                label_part: Optional[InlayHintLabelPart] = None) -> None:
31         self.handle_inlay_hint_text_edits(session_name, inlay_hint, phantom_uuid)
32         self.handle_label_part_command(session_name, label_part)
33 
34     def handle_inlay_hint_text_edits(self, session_name: str, inlay_hint: InlayHint, phantom_uuid: str) -> None:
35         session = self.session_by_name(session_name, 'inlayHintProvider')
36         if not session:
37             return
38         text_edits = inlay_hint.get('textEdits')
39         if not text_edits:
40             return
41         for sb in session.session_buffers_async():
42             sb.remove_inlay_hint_phantom(phantom_uuid)
43         apply_text_edits_to_view(text_edits, self.view)
44 
45     def handle_label_part_command(self, session_name: str, label_part: Optional[InlayHintLabelPart] = None) -> None:
46         if not label_part:
47             return
48         command = label_part.get('command')
49         if not command:
50             return
51         args = {
52             "session_name": session_name,
53             "command_name": command["command"],
54             "command_args": command.get("arguments")
55         }
56         self.view.run_command("lsp_execute", args)
57 
58 
59 def inlay_hint_to_phantom(view: sublime.View, inlay_hint: InlayHint, session: Session) -> sublime.Phantom:
60     position = inlay_hint["position"]  # type: ignore
61     region = sublime.Region(point_to_offset(Point.from_lsp(position), view))
62     phantom_uuid = str(uuid.uuid4())
63     content = get_inlay_hint_html(view, inlay_hint, session, phantom_uuid)
64     p = sublime.Phantom(region, content, sublime.LAYOUT_INLINE)
65     setattr(p, 'lsp_uuid', phantom_uuid)
66     return p
67 
68 
69 def get_inlay_hint_html(view: sublime.View, inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:
70     tooltip = format_inlay_hint_tooltip(inlay_hint.get("tooltip"))
71     label = format_inlay_hint_label(inlay_hint, session, phantom_uuid)
72     font = view.settings().get('font_face') or "monospace"
73     html = """
74     <body id="lsp-inlay-hint">
75         <style>
76             .inlay-hint {{
77                 color: color(var(--foreground) alpha(0.6));
78                 background-color: color(var(--foreground) alpha(0.08));
79                 border-radius: 4px;
80                 padding: 0.05em 4px;
81                 font-size: 0.9em;
82                 font-family: {font};
83             }}
84 
85             .inlay-hint a {{
86                 color: color(var(--foreground) alpha(0.6));
87                 text-decoration: none;
88             }}
89         </style>
90         <div class="inlay-hint" title="{tooltip}">
91             {label}
92         </div>
93     </body>
94     """.format(
95         tooltip=tooltip,
96         font=font,
97         label=label
98     )
99     return html
100 
101 
102 def format_inlay_hint_tooltip(tooltip: Optional[Union[str, MarkupContent]]) -> str:
103     if isinstance(tooltip, str):
104         return html.escape(tooltip)
105     if isinstance(tooltip, dict):  # MarkupContent
106         return html.escape(tooltip.get('value') or "")
107     return ""
108 
109 
110 def format_inlay_hint_label(inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:
111     result = ""
112     can_resolve_inlay_hint = session.has_capability('inlayHintProvider.resolveProvider')
113     label = inlay_hint['label']  # type: ignore
114     is_clickable = bool(inlay_hint.get('textEdits')) or can_resolve_inlay_hint
115     if isinstance(label, str):
116         if is_clickable:
117             inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {
118                 'session_name': session.config.name,
119                 'inlay_hint': inlay_hint,
120                 'phantom_uuid': phantom_uuid
121             })
122             result += '<a href="{command}">'.format(command=inlay_hint_click_command)
123         result += html.escape(label)
124         if is_clickable:
125             result += "</a>"
126         return result
127 
128     for label_part in label:
129         value = ""
130         is_clickable = is_clickable or bool(label_part.get('command'))
131         if is_clickable:
132             inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {
133                 'session_name': session.config.name,
134                 'inlay_hint': inlay_hint,
135                 'phantom_uuid': phantom_uuid,
136                 'label_part': label_part
137             })
138             value += '<a href="{command}">'.format(command=inlay_hint_click_command)
139         value += html.escape(label_part['value'])
140         if is_clickable:
141             value += "</a>"
142         # InlayHintLabelPart.location is not supported
143         result += "<div title=\"{tooltip}\">{value}</div>".format(
144             tooltip=format_inlay_hint_tooltip(label_part.get("tooltip")),
145             value=value
146         )
147     return result
148
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/plugin/inlay_hint.py b/plugin/inlay_hint.py
--- a/plugin/inlay_hint.py
+++ b/plugin/inlay_hint.py
@@ -1,7 +1,7 @@
 from .core.protocol import InlayHintLabelPart, MarkupContent, Point, InlayHint, Request
 from .core.registry import LspTextCommand
 from .core.sessions import Session
-from .core.typing import Optional, Union
+from .core.typing import cast, Optional, Union
 from .core.views import point_to_offset
 from .formatting import apply_text_edits_to_view
 import html
@@ -57,7 +57,7 @@
 
 
 def inlay_hint_to_phantom(view: sublime.View, inlay_hint: InlayHint, session: Session) -> sublime.Phantom:
-    position = inlay_hint["position"]  # type: ignore
+    position = inlay_hint["position"]
     region = sublime.Region(point_to_offset(Point.from_lsp(position), view))
     phantom_uuid = str(uuid.uuid4())
     content = get_inlay_hint_html(view, inlay_hint, session, phantom_uuid)
@@ -110,13 +110,13 @@
 def format_inlay_hint_label(inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:
     result = ""
     can_resolve_inlay_hint = session.has_capability('inlayHintProvider.resolveProvider')
-    label = inlay_hint['label']  # type: ignore
+    label = inlay_hint['label']
     is_clickable = bool(inlay_hint.get('textEdits')) or can_resolve_inlay_hint
     if isinstance(label, str):
         if is_clickable:
             inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {
                 'session_name': session.config.name,
-                'inlay_hint': inlay_hint,
+                'inlay_hint': cast(dict, inlay_hint),
                 'phantom_uuid': phantom_uuid
             })
             result += '<a href="{command}">'.format(command=inlay_hint_click_command)
@@ -131,16 +131,16 @@
         if is_clickable:
             inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {
                 'session_name': session.config.name,
-                'inlay_hint': inlay_hint,
+                'inlay_hint': cast(dict, inlay_hint),
                 'phantom_uuid': phantom_uuid,
-                'label_part': label_part
+                'label_part': cast(dict, label_part)
             })
             value += '<a href="{command}">'.format(command=inlay_hint_click_command)
         value += html.escape(label_part['value'])
         if is_clickable:
             value += "</a>"
         # InlayHintLabelPart.location is not supported
-        result += "<div title=\"{tooltip}\">{value}</div>".format(
+        result += "<span title=\"{tooltip}\">{value}</span>".format(
             tooltip=format_inlay_hint_tooltip(label_part.get("tooltip")),
             value=value
         )

{"golden_diff": "diff --git a/plugin/inlay_hint.py b/plugin/inlay_hint.py\n--- a/plugin/inlay_hint.py\n+++ b/plugin/inlay_hint.py\n@@ -1,7 +1,7 @@\n from .core.protocol import InlayHintLabelPart, MarkupContent, Point, InlayHint, Request\n from .core.registry import LspTextCommand\n from .core.sessions import Session\n-from .core.typing import Optional, Union\n+from .core.typing import cast, Optional, Union\n from .core.views import point_to_offset\n from .formatting import apply_text_edits_to_view\n import html\n@@ -57,7 +57,7 @@\n \n \n def inlay_hint_to_phantom(view: sublime.View, inlay_hint: InlayHint, session: Session) -> sublime.Phantom:\n-    position = inlay_hint[\"position\"]  # type: ignore\n+    position = inlay_hint[\"position\"]\n     region = sublime.Region(point_to_offset(Point.from_lsp(position), view))\n     phantom_uuid = str(uuid.uuid4())\n     content = get_inlay_hint_html(view, inlay_hint, session, phantom_uuid)\n@@ -110,13 +110,13 @@\n def format_inlay_hint_label(inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:\n     result = \"\"\n     can_resolve_inlay_hint = session.has_capability('inlayHintProvider.resolveProvider')\n-    label = inlay_hint['label']  # type: ignore\n+    label = inlay_hint['label']\n     is_clickable = bool(inlay_hint.get('textEdits')) or can_resolve_inlay_hint\n     if isinstance(label, str):\n         if is_clickable:\n             inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {\n                 'session_name': session.config.name,\n-                'inlay_hint': inlay_hint,\n+                'inlay_hint': cast(dict, inlay_hint),\n                 'phantom_uuid': phantom_uuid\n             })\n             result += '<a href=\"{command}\">'.format(command=inlay_hint_click_command)\n@@ -131,16 +131,16 @@\n         if is_clickable:\n             inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {\n                 'session_name': session.config.name,\n-                'inlay_hint': inlay_hint,\n+                'inlay_hint': cast(dict, inlay_hint),\n                 'phantom_uuid': phantom_uuid,\n-                'label_part': label_part\n+                'label_part': cast(dict, label_part)\n             })\n             value += '<a href=\"{command}\">'.format(command=inlay_hint_click_command)\n         value += html.escape(label_part['value'])\n         if is_clickable:\n             value += \"</a>\"\n         # InlayHintLabelPart.location is not supported\n-        result += \"<div title=\\\"{tooltip}\\\">{value}</div>\".format(\n+        result += \"<span title=\\\"{tooltip}\\\">{value}</span>\".format(\n             tooltip=format_inlay_hint_tooltip(label_part.get(\"tooltip\")),\n             value=value\n         )\n", "issue": "LSP-rust-analyzer inlay hints appear on multiple lines\n**Describe the bug**\r\ninlay hints in `LSP-rust-analyzer` appear on multiple lines since https://github.com/rust-lang/rust-analyzer/pull/13699\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n\r\n1. use the rust source file:\r\n\r\n```rs\r\nfn main() {\r\n\tlet v = vec![\r\n\t\t\"1\".to_string(),\r\n\t\t\"1\".to_string(),\r\n\t\t\"1\".to_string(),\r\n\t\t\"1\".to_string(),\r\n\t\t\"1\".to_string(),\r\n\t];\r\n\tdbg!(&v);\r\n}\r\n```\r\n\r\n2. settings files:\r\n\r\n```js\r\n// User/LSP.sublime-settings\r\n// Settings in here override those in \"LSP/LSP.sublime-settings\"\r\n{\r\n\t\"show_inlay_hints\": true,\r\n}\r\n```\r\n\r\n```js\r\n// User/LSP-rust-analyzer.sublime-settings\r\n// Settings in here override those in \"LSP-rust-analyzer/LSP-rust-analyzer.sublime-settings\"\r\n{\r\n\t\"command\": [\"rust-analyzer-2022-12-26\"],\r\n\t\"settings\": {\r\n\t\t// default: true\r\n\t\t\"rust-analyzer.inlayHints.locationLinks\": true,\r\n\t},\r\n}\r\n\r\n```\r\n\r\n3. see the inlay hints broken down in multiple lines\r\n\r\n![](https://user-images.githubusercontent.com/1024798/209812702-f2a89cf0-175d-493c-bb85-d31a20b42bf6.png)\r\n\r\n**Expected behavior**\r\n\r\nthe inlay hints should be on one line\r\n\r\n![](https://user-images.githubusercontent.com/1024798/209812987-03d51c4e-a601-47f6-8d97-b4e3841354ec.png)\r\n\r\n**Environment (please complete the following information):**\r\n- OS: Debian 11.6\r\n- Sublime Text version: 4143\r\n- LSP version: v1.20.0\r\n- Language servers used: LSP-rust-analyzer v1.1.0\r\n\r\n```\r\n> rust-analyzer-2022-12-26 --version\r\nrust-analyzer 0.3.1334-standalone\r\n```\r\n\r\n**Additional context**\r\n\r\nthe `\"rust-analyzer.inlayHints.locationLinks\": false` setting (default: `true`) makes them appear again on one line\r\n\r\nLSP panel output:\r\n\r\n**rust-analyzer-2022-12-19**\r\n\r\n```py\r\n:: --> rust-analyzer textDocument/inlayHint(19): {'textDocument': {'uri': 'file:///home/it/Desktop/asd/src/main.rs'}, 'range': {'end': {'character': 0, 'line': 10}, 'start': {'character': 0, 'line': 0}}}\r\n:: <<< rust-analyzer 19: [\r\n    {\r\n        'kind': 1,\r\n        'tooltip': ': Vec<String>',\r\n        'paddingRight': False,\r\n        'label': ': Vec<String>',\r\n        'paddingLeft': False,\r\n        'position': {'character': 6, 'line': 1},\r\n        'data': {\r\n            'text_document': {'uri': 'file:///home/it/Desktop/asd/src/main.rs', 'version': 24},\r\n            'position': {'end': {'character': 6, 'line': 1}, 'start': {'character': 5, 'line': 1}},\r\n        },\r\n    }\r\n]\r\n```\r\n\r\n**rust-analyzer-2022-12-26**\r\n\r\n```py\r\n:: --> rust-analyzer textDocument/inlayHint(40): {'textDocument': {'uri': 'file:///home/it/Desktop/asd/src/main.rs'}, 'range': {'end': {'character': 0, 'line': 11}, 'start': {'character': 0, 'line': 0}}}\r\n:: <<< rust-analyzer 40: [\r\n    {\r\n        'kind': 1,\r\n        'tooltip': ': Vec<String>',\r\n        'paddingRight': False,\r\n        'label': [\r\n            {'value': ': '},\r\n            {\r\n                'value': 'Vec',\r\n                'location': {\r\n                    'uri': 'file:///home/it/.local/lib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs',\r\n                    'range': {'end': {'character': 14, 'line': 399}, 'start': {'character': 11, 'line': 399}},\r\n                },\r\n            },\r\n            {'value': '<'},\r\n            {\r\n                'value': 'String',\r\n                'location': {\r\n                    'uri': 'file:///home/it/.local/lib/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/string.rs',\r\n                    'range': {'end': {'character': 17, 'line': 366}, 'start': {'character': 11, 'line': 366}},\r\n                },\r\n            },\r\n            {'value': '>'},\r\n        ],\r\n        'paddingLeft': False,\r\n        'position': {'character': 6, 'line': 1},\r\n        'data': {\r\n            'text_document': {'uri': 'file:///home/it/Desktop/asd/src/main.rs', 'version': 8},\r\n            'position': {'end': {'character': 6, 'line': 1}, 'start': {'character': 5, 'line': 1}},\r\n        },\r\n    }\r\n]\r\n```\r\n\r\n\r\n\n", "before_files": [{"content": "from .core.protocol import InlayHintLabelPart, MarkupContent, Point, InlayHint, Request\nfrom .core.registry import LspTextCommand\nfrom .core.sessions import Session\nfrom .core.typing import Optional, Union\nfrom .core.views import point_to_offset\nfrom .formatting import apply_text_edits_to_view\nimport html\nimport sublime\nimport uuid\n\n\nclass LspInlayHintClickCommand(LspTextCommand):\n    capability = 'inlayHintProvider'\n\n    def run(self, _edit: sublime.Edit, session_name: str, inlay_hint: InlayHint, phantom_uuid: str,\n            event: Optional[dict] = None, label_part: Optional[InlayHintLabelPart] = None) -> None:\n        # Insert textEdits for the given inlay hint.\n        # If a InlayHintLabelPart was clicked, label_part will be passed as an argument to the LspInlayHintClickCommand\n        # and InlayHintLabelPart.command will be executed.\n        session = self.session_by_name(session_name, 'inlayHintProvider')\n        if session and session.has_capability('inlayHintProvider.resolveProvider'):\n            request = Request.resolveInlayHint(inlay_hint, self.view)\n            session.send_request_async(\n                request,\n                lambda response: self.handle(session_name, response, phantom_uuid, label_part))\n            return\n        self.handle(session_name, inlay_hint, phantom_uuid, label_part)\n\n    def handle(self, session_name: str, inlay_hint: InlayHint, phantom_uuid: str,\n               label_part: Optional[InlayHintLabelPart] = None) -> None:\n        self.handle_inlay_hint_text_edits(session_name, inlay_hint, phantom_uuid)\n        self.handle_label_part_command(session_name, label_part)\n\n    def handle_inlay_hint_text_edits(self, session_name: str, inlay_hint: InlayHint, phantom_uuid: str) -> None:\n        session = self.session_by_name(session_name, 'inlayHintProvider')\n        if not session:\n            return\n        text_edits = inlay_hint.get('textEdits')\n        if not text_edits:\n            return\n        for sb in session.session_buffers_async():\n            sb.remove_inlay_hint_phantom(phantom_uuid)\n        apply_text_edits_to_view(text_edits, self.view)\n\n    def handle_label_part_command(self, session_name: str, label_part: Optional[InlayHintLabelPart] = None) -> None:\n        if not label_part:\n            return\n        command = label_part.get('command')\n        if not command:\n            return\n        args = {\n            \"session_name\": session_name,\n            \"command_name\": command[\"command\"],\n            \"command_args\": command.get(\"arguments\")\n        }\n        self.view.run_command(\"lsp_execute\", args)\n\n\ndef inlay_hint_to_phantom(view: sublime.View, inlay_hint: InlayHint, session: Session) -> sublime.Phantom:\n    position = inlay_hint[\"position\"]  # type: ignore\n    region = sublime.Region(point_to_offset(Point.from_lsp(position), view))\n    phantom_uuid = str(uuid.uuid4())\n    content = get_inlay_hint_html(view, inlay_hint, session, phantom_uuid)\n    p = sublime.Phantom(region, content, sublime.LAYOUT_INLINE)\n    setattr(p, 'lsp_uuid', phantom_uuid)\n    return p\n\n\ndef get_inlay_hint_html(view: sublime.View, inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:\n    tooltip = format_inlay_hint_tooltip(inlay_hint.get(\"tooltip\"))\n    label = format_inlay_hint_label(inlay_hint, session, phantom_uuid)\n    font = view.settings().get('font_face') or \"monospace\"\n    html = \"\"\"\n    <body id=\"lsp-inlay-hint\">\n        <style>\n            .inlay-hint {{\n                color: color(var(--foreground) alpha(0.6));\n                background-color: color(var(--foreground) alpha(0.08));\n                border-radius: 4px;\n                padding: 0.05em 4px;\n                font-size: 0.9em;\n                font-family: {font};\n            }}\n\n            .inlay-hint a {{\n                color: color(var(--foreground) alpha(0.6));\n                text-decoration: none;\n            }}\n        </style>\n        <div class=\"inlay-hint\" title=\"{tooltip}\">\n            {label}\n        </div>\n    </body>\n    \"\"\".format(\n        tooltip=tooltip,\n        font=font,\n        label=label\n    )\n    return html\n\n\ndef format_inlay_hint_tooltip(tooltip: Optional[Union[str, MarkupContent]]) -> str:\n    if isinstance(tooltip, str):\n        return html.escape(tooltip)\n    if isinstance(tooltip, dict):  # MarkupContent\n        return html.escape(tooltip.get('value') or \"\")\n    return \"\"\n\n\ndef format_inlay_hint_label(inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:\n    result = \"\"\n    can_resolve_inlay_hint = session.has_capability('inlayHintProvider.resolveProvider')\n    label = inlay_hint['label']  # type: ignore\n    is_clickable = bool(inlay_hint.get('textEdits')) or can_resolve_inlay_hint\n    if isinstance(label, str):\n        if is_clickable:\n            inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {\n                'session_name': session.config.name,\n                'inlay_hint': inlay_hint,\n                'phantom_uuid': phantom_uuid\n            })\n            result += '<a href=\"{command}\">'.format(command=inlay_hint_click_command)\n        result += html.escape(label)\n        if is_clickable:\n            result += \"</a>\"\n        return result\n\n    for label_part in label:\n        value = \"\"\n        is_clickable = is_clickable or bool(label_part.get('command'))\n        if is_clickable:\n            inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {\n                'session_name': session.config.name,\n                'inlay_hint': inlay_hint,\n                'phantom_uuid': phantom_uuid,\n                'label_part': label_part\n            })\n            value += '<a href=\"{command}\">'.format(command=inlay_hint_click_command)\n        value += html.escape(label_part['value'])\n        if is_clickable:\n            value += \"</a>\"\n        # InlayHintLabelPart.location is not supported\n        result += \"<div title=\\\"{tooltip}\\\">{value}</div>\".format(\n            tooltip=format_inlay_hint_tooltip(label_part.get(\"tooltip\")),\n            value=value\n        )\n    return result\n", "path": "plugin/inlay_hint.py"}], "after_files": [{"content": "from .core.protocol import InlayHintLabelPart, MarkupContent, Point, InlayHint, Request\nfrom .core.registry import LspTextCommand\nfrom .core.sessions import Session\nfrom .core.typing import cast, Optional, Union\nfrom .core.views import point_to_offset\nfrom .formatting import apply_text_edits_to_view\nimport html\nimport sublime\nimport uuid\n\n\nclass LspInlayHintClickCommand(LspTextCommand):\n    capability = 'inlayHintProvider'\n\n    def run(self, _edit: sublime.Edit, session_name: str, inlay_hint: InlayHint, phantom_uuid: str,\n            event: Optional[dict] = None, label_part: Optional[InlayHintLabelPart] = None) -> None:\n        # Insert textEdits for the given inlay hint.\n        # If a InlayHintLabelPart was clicked, label_part will be passed as an argument to the LspInlayHintClickCommand\n        # and InlayHintLabelPart.command will be executed.\n        session = self.session_by_name(session_name, 'inlayHintProvider')\n        if session and session.has_capability('inlayHintProvider.resolveProvider'):\n            request = Request.resolveInlayHint(inlay_hint, self.view)\n            session.send_request_async(\n                request,\n                lambda response: self.handle(session_name, response, phantom_uuid, label_part))\n            return\n        self.handle(session_name, inlay_hint, phantom_uuid, label_part)\n\n    def handle(self, session_name: str, inlay_hint: InlayHint, phantom_uuid: str,\n               label_part: Optional[InlayHintLabelPart] = None) -> None:\n        self.handle_inlay_hint_text_edits(session_name, inlay_hint, phantom_uuid)\n        self.handle_label_part_command(session_name, label_part)\n\n    def handle_inlay_hint_text_edits(self, session_name: str, inlay_hint: InlayHint, phantom_uuid: str) -> None:\n        session = self.session_by_name(session_name, 'inlayHintProvider')\n        if not session:\n            return\n        text_edits = inlay_hint.get('textEdits')\n        if not text_edits:\n            return\n        for sb in session.session_buffers_async():\n            sb.remove_inlay_hint_phantom(phantom_uuid)\n        apply_text_edits_to_view(text_edits, self.view)\n\n    def handle_label_part_command(self, session_name: str, label_part: Optional[InlayHintLabelPart] = None) -> None:\n        if not label_part:\n            return\n        command = label_part.get('command')\n        if not command:\n            return\n        args = {\n            \"session_name\": session_name,\n            \"command_name\": command[\"command\"],\n            \"command_args\": command.get(\"arguments\")\n        }\n        self.view.run_command(\"lsp_execute\", args)\n\n\ndef inlay_hint_to_phantom(view: sublime.View, inlay_hint: InlayHint, session: Session) -> sublime.Phantom:\n    position = inlay_hint[\"position\"]\n    region = sublime.Region(point_to_offset(Point.from_lsp(position), view))\n    phantom_uuid = str(uuid.uuid4())\n    content = get_inlay_hint_html(view, inlay_hint, session, phantom_uuid)\n    p = sublime.Phantom(region, content, sublime.LAYOUT_INLINE)\n    setattr(p, 'lsp_uuid', phantom_uuid)\n    return p\n\n\ndef get_inlay_hint_html(view: sublime.View, inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:\n    tooltip = format_inlay_hint_tooltip(inlay_hint.get(\"tooltip\"))\n    label = format_inlay_hint_label(inlay_hint, session, phantom_uuid)\n    font = view.settings().get('font_face') or \"monospace\"\n    html = \"\"\"\n    <body id=\"lsp-inlay-hint\">\n        <style>\n            .inlay-hint {{\n                color: color(var(--foreground) alpha(0.6));\n                background-color: color(var(--foreground) alpha(0.08));\n                border-radius: 4px;\n                padding: 0.05em 4px;\n                font-size: 0.9em;\n                font-family: {font};\n            }}\n\n            .inlay-hint a {{\n                color: color(var(--foreground) alpha(0.6));\n                text-decoration: none;\n            }}\n        </style>\n        <div class=\"inlay-hint\" title=\"{tooltip}\">\n            {label}\n        </div>\n    </body>\n    \"\"\".format(\n        tooltip=tooltip,\n        font=font,\n        label=label\n    )\n    return html\n\n\ndef format_inlay_hint_tooltip(tooltip: Optional[Union[str, MarkupContent]]) -> str:\n    if isinstance(tooltip, str):\n        return html.escape(tooltip)\n    if isinstance(tooltip, dict):  # MarkupContent\n        return html.escape(tooltip.get('value') or \"\")\n    return \"\"\n\n\ndef format_inlay_hint_label(inlay_hint: InlayHint, session: Session, phantom_uuid: str) -> str:\n    result = \"\"\n    can_resolve_inlay_hint = session.has_capability('inlayHintProvider.resolveProvider')\n    label = inlay_hint['label']\n    is_clickable = bool(inlay_hint.get('textEdits')) or can_resolve_inlay_hint\n    if isinstance(label, str):\n        if is_clickable:\n            inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {\n                'session_name': session.config.name,\n                'inlay_hint': cast(dict, inlay_hint),\n                'phantom_uuid': phantom_uuid\n            })\n            result += '<a href=\"{command}\">'.format(command=inlay_hint_click_command)\n        result += html.escape(label)\n        if is_clickable:\n            result += \"</a>\"\n        return result\n\n    for label_part in label:\n        value = \"\"\n        is_clickable = is_clickable or bool(label_part.get('command'))\n        if is_clickable:\n            inlay_hint_click_command = sublime.command_url('lsp_inlay_hint_click', {\n                'session_name': session.config.name,\n                'inlay_hint': cast(dict, inlay_hint),\n                'phantom_uuid': phantom_uuid,\n                'label_part': cast(dict, label_part)\n            })\n            value += '<a href=\"{command}\">'.format(command=inlay_hint_click_command)\n        value += html.escape(label_part['value'])\n        if is_clickable:\n            value += \"</a>\"\n        # InlayHintLabelPart.location is not supported\n        result += \"<span title=\\\"{tooltip}\\\">{value}</span>\".format(\n            tooltip=format_inlay_hint_tooltip(label_part.get(\"tooltip\")),\n            value=value\n        )\n    return result\n", "path": "plugin/inlay_hint.py"}]}