diff --git a/libs/natls/src/main/java/org/amshove/natls/codelens/InputPreviewCodeLensProvider.java b/libs/natls/src/main/java/org/amshove/natls/codelens/InputPreviewCodeLensProvider.java index 5f4d0f44d..37a942963 100644 --- a/libs/natls/src/main/java/org/amshove/natls/codelens/InputPreviewCodeLensProvider.java +++ b/libs/natls/src/main/java/org/amshove/natls/codelens/InputPreviewCodeLensProvider.java @@ -30,7 +30,7 @@ public List provideCodeLens(LanguageServerFile file) for (int i = 0; i < inputs.size(); i++) { var input = inputs.get(i); - var lens = codeLensWithoutCommand("Open Preview", LspUtil.toRange(input)); + var lens = codeLensWithoutCommand("Open Preview", LspUtil.toRange(input.diagnosticPosition())); var params = new InputStructureParams(); params.setUri(file.getUri()); params.setInputIndex(i); diff --git a/libs/natls/src/test/java/org/amshove/natls/codelens/InputPreviewCodelensTests.java b/libs/natls/src/test/java/org/amshove/natls/codelens/InputPreviewCodelensTests.java index 245add6c8..e98ef8ef6 100644 --- a/libs/natls/src/test/java/org/amshove/natls/codelens/InputPreviewCodelensTests.java +++ b/libs/natls/src/test/java/org/amshove/natls/codelens/InputPreviewCodelensTests.java @@ -63,4 +63,31 @@ void codeLensShouldNotBeShownWhenFeatureIsDisabledLater() configureLSConfig(newConfig); testCodeLens(document, lenses -> assertThat(lenses).noneMatch(l -> l.getCommand().getTitle().contains("Open Preview"))); } + + @Test + void codeLensShouldBeShownAtTheIncludeOfACopyCode() + { + var config = LSConfiguration.createDefault(); + config.getMaps().setEnablePreview(true); + configureLSConfig(config); + createOrSaveFile("LIBONE", "MYCC.NSC", """ + INPUT 'Hello + + INPUT 'Hello 2' + """); + var document = createOrSaveFile("LIBONE", "PROG.NSP", """ + DEFINE DATA LOCAL + END-DEFINE + INCLUDE MYCC + END + """); + + testCodeLens( + document, + // all on the line of the INCLUDE + lenses -> assertThat(lenses.stream().filter(l -> l.getCommand().getTitle().contains("Open Preview"))) + .isNotEmpty() + .allMatch(l -> l.getRange().getStart().getLine() == 2) + ); + } }