Repository: sublimelsp/LSP

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}},
        },
    }
]
```





Discussion:

Resolving patch:
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 handle_label_part_command(self, session_name: str, label_part: Optional[Inla
 
 
 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_tooltip(tooltip: Optional[Union[str, MarkupContent]]) -> s
 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 @@ def format_inlay_hint_label(inlay_hint: InlayHint, session: Session, phantom_uui
         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
         )


Test patch: