rcjsuen / dockerfile-language-service

Dockerfile language service for providing an API to create feature-rich Dockerfile editors in JavaScript.
MIT License
16 stars 2 forks source link

Incorrect completion suggestions returned for an instruction keyword that spans multiple lines #60

Closed rcjsuen closed 3 years ago

rcjsuen commented 4 years ago
FR\

OM scratch
$ docker build .
Sending build context to Docker daemon  38.15MB
[WARNING]: Empty continuation line found in:
    FROM scratch
[WARNING]: Empty continuation lines will become errors in a future release.
Step 1/1 : FROM scratch
 ---> 
No image was generated. Is your Dockerfile empty?

Although the strange text should be combined to form a single word FROM, our content assist processor does not appear to be accounting for this and returns the wrong completion items if we try to ask it for items on the third line.

import { DockerfileLanguageServiceFactory } from 'dockerfile-language-service';
const service = DockerfileLanguageServiceFactory.createLanguageService();
const items = service.computeCompletionItems(
    "FR\\\n\nOM scratch",
    { line: 2, character: 1 }
);
console.log(items);
[ { data: 'ONBUILD',
    textEdit: { range: [Object], newText: 'ONBUILD' },
    label: 'ONBUILD',
    kind: 14,
    insertTextFormat: 1 } ]

The code should be considering FRO instead of O for its prefix.