Skip to content

Commit d2f7078

Browse files
committed
Fix unnessary completion
1 parent 58398d1 commit d2f7078

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

server/src/analyser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ export default class Analyzer {
359359
return getAllDeclarationsInTree({ uri, tree })
360360
}
361361

362+
/**
363+
* Get the document for the given URI.
364+
*/
365+
public getDocument(uri: string): TextDocument | undefined {
366+
return this.uriToAnalyzedDocument[uri]?.document
367+
}
368+
362369
// TODO: move somewhere else than the analyzer...
363370
public async getExplainshellDocumentation({
364371
params,

server/src/server.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,18 @@ export default class BashServer {
450450
return []
451451
}
452452

453+
if (!word) {
454+
const nextCharacter = this.analyzer.getDocument(params.textDocument.uri)?.getText({
455+
start: params.position,
456+
end: { ...params.position, character: params.position.character + 1 },
457+
})
458+
const isNextCharacterSpaceOrEmpty = nextCharacter === '' || nextCharacter === ' '
459+
if (!isNextCharacterSpaceOrEmpty) {
460+
// We are in the middle of something, so don't complete
461+
return []
462+
}
463+
}
464+
453465
let options: string[] = []
454466
if (word && word.startsWith('-')) {
455467
const commandName = this.analyzer.commandNameAtPoint(

0 commit comments

Comments
 (0)