Skip to content

Commit d73e931

Browse files
committed
fix: only provide completions if a twind dts file (local or bundled) has been found
1 parent 3a463d9 commit d73e931

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/language-service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ export class TwindLanguageService implements TemplateLanguageService {
120120
this._twind = new Twind(typescript, info, configurationManager, logger)
121121
}
122122

123+
public get enabled(): boolean {
124+
return this._twind.enabled
125+
}
126+
123127
public getCompletionsAtPosition(
124128
context: TemplateContext,
125129
position: ts.LineAndCharacter,

src/plugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class TwindPlugin {
8080

8181
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8282
getCompletionEntryDetails: (fileName, position, name, ...rest: any[]) => {
83-
if (enable) {
83+
if (enable && ttls.enabled) {
8484
const context = helper.getTemplate(fileName, position)
8585

8686
if (context) {
@@ -97,7 +97,7 @@ export class TwindPlugin {
9797
},
9898

9999
getCompletionsAtPosition: (fileName, position, options) => {
100-
if (enable) {
100+
if (enable && ttls.enabled) {
101101
const context = helper.getTemplate(fileName, position)
102102

103103
if (context) {
@@ -112,7 +112,7 @@ export class TwindPlugin {
112112
},
113113

114114
getQuickInfoAtPosition: (fileName, position) => {
115-
if (enable) {
115+
if (enable && ttls.enabled) {
116116
const context = helper.getTemplate(fileName, position)
117117

118118
if (context) {
@@ -136,7 +136,7 @@ export class TwindPlugin {
136136
getSemanticDiagnostics: (fileName) => {
137137
const diagnostics = [...languageService.getSemanticDiagnostics(fileName)]
138138

139-
if (enable) {
139+
if (enable && ttls.enabled) {
140140
helper.getAllTemplates(fileName).forEach((context) => {
141141
for (const diagnostic of ttls.getSemanticDiagnostics(context)) {
142142
diagnostics.push({

src/twind.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ export class Twind {
225225
})
226226
}
227227

228+
public get enabled(): boolean {
229+
return Boolean(this.state?.twindDTSSourceFile)
230+
}
231+
228232
private _reset(): void {
229233
this.logger.log('reset state')
230234
this._state = this._completions = undefined

0 commit comments

Comments
 (0)