summaryrefslogtreecommitdiff
path: root/support/texlab/tests/test_hover_latex_label.rs
blob: 94a96ad53383322af0eacb150946e3d59781a890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pub mod support;

use lsp_types::*;
use std::sync::Arc;
use support::capabilities::CLIENT_FULL_CAPABILITIES;
use support::*;
use tokio::fs;

const SCENARIO: &str = "hover/latex/label";

#[tokio::test]
async fn reload_aux() {
    let scenario = Scenario::new(SCENARIO, Arc::new(Box::new(tex::Unknown)));
    scenario.initialize(&CLIENT_FULL_CAPABILITIES).await;
    scenario.open("section.tex").await;
    let position = Position::new(3, 10);
    let identifier = TextDocumentIdentifier::new(scenario.uri("section.tex").into());
    let params = TextDocumentPositionParams::new(identifier, position);
    let contents = scenario
        .server
        .execute_async(|svr| svr.hover(params.clone()))
        .await
        .unwrap()
        .unwrap()
        .contents;

    assert_eq!(
        contents,
        HoverContents::Markup(MarkupContent {
            kind: MarkupKind::PlainText,
            value: "Section (Foo)".into()
        })
    );

    let aux_path = scenario
        .uri("section.tex")
        .to_file_path()
        .unwrap()
        .with_extension("aux");
    fs::write(aux_path, "\\newlabel{sec:foo}{{1}{1}}")
        .await
        .unwrap();

    let contents = scenario
        .server
        .execute_async(|svr| svr.hover(params))
        .await
        .unwrap()
        .unwrap()
        .contents;

    assert_eq!(
        contents,
        HoverContents::Markup(MarkupContent {
            kind: MarkupKind::PlainText,
            value: "Section 1 (Foo)".into()
        })
    );
}