Skip to content

Commit 7a51ff0

Browse files
committed
Docs of cfn language are always templates
1 parent 341036b commit 7a51ff0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/document/Document.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export class Document {
6565
}
6666

6767
private detectCfnFileType(): CloudFormationFileType {
68+
// If languageId is cloudformation, treat as template
69+
if (this.languageId === 'cloudformation') {
70+
return CloudFormationFileType.Template;
71+
}
72+
6873
if (!this.cachedParsedContent || typeof this.cachedParsedContent !== 'object') {
6974
return CloudFormationFileType.Unknown;
7075
}

tst/unit/document/Document.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ describe('Document', () => {
166166

167167
describe('CloudFormation detection', () => {
168168
describe('should detect CloudFormation templates', () => {
169+
it('with languageId cloudformation', () => {
170+
const content = '{}'; // Empty content
171+
const textDocument = TextDocument.create('file:///test.json', 'cloudformation', 1, content);
172+
const doc = new Document(textDocument);
173+
174+
expect(doc.cfnFileType).toBe(CloudFormationFileType.Template);
175+
});
176+
169177
it('with AWSTemplateFormatVersion', () => {
170178
const content = '{"AWSTemplateFormatVersion": "2010-09-09"}';
171179
const textDocument = TextDocument.create('file:///test.json', 'json', 1, content);

0 commit comments

Comments
 (0)