Skip to content

Commit 08e542a

Browse files
committed
Fix: Severly improve autocompletion
1 parent 43fffc1 commit 08e542a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/features/dfdElements/outputPortEditUi.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ class MonacoEditorDfdBehaviorCompletionProvider implements monaco.languages.Comp
193193
if (
194194
model.getValueInRange(
195195
new monaco.Range(position.lineNumber, position.column - 1, position.lineNumber, position.column),
196-
) === "{"
196+
) === "{" &&
197+
model.getValueInRange(
198+
new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column + 1),
199+
) !== "}"
197200
) {
198201
return {
199202
suggestions: [curlyBracketCompletion],
@@ -228,19 +231,24 @@ class MonacoEditorDfdBehaviorCompletionProvider implements monaco.languages.Comp
228231

229232
// Check if we're inside the input list (i.e., inside first curly braces `{}`)
230233
const openBraceIndex = line.indexOf("{");
231-
const firstSemicolonIndex = line.indexOf(";");
234+
const closingBraceIndex = line.indexOf("}");
232235

236+
console.log("Moin" + column);
237+
console.log("Moin" + openBraceIndex);
238+
console.log("Moin" + closingBraceIndex);
239+
console.log("Moin" + (openBraceIndex !== -1 && (closingBraceIndex === -1 || column <= closingBraceIndex)));
233240
// If the first semicolon hasn't been typed yet, assume we're inside the input list
234-
if (openBraceIndex !== -1 && (firstSemicolonIndex === -1 || column < firstSemicolonIndex)) {
241+
if (openBraceIndex !== -1 && (closingBraceIndex === -1 || column <= closingBraceIndex + 1)) {
235242
// Inside `{List of available inputs}` section
236243
return this.getInputCompletions(model, position, availableInputs);
237244
}
238245

239246
// If the second semicolon hasn't been typed yet, assume we're typing in the term section or outPorts list
247+
const firstSemicolonIndex = line.indexOf(";");
240248
const secondSemicolonIndex = line.indexOf(";", firstSemicolonIndex + 1);
241249
const secondOpenBraceIndex = line.indexOf("{", openBraceIndex + 1);
242250

243-
if (secondSemicolonIndex !== -1 && column > secondSemicolonIndex) {
251+
if (secondSemicolonIndex !== -1 && column > secondSemicolonIndex + 1) {
244252
// If the second semicolon hasn't been typed but we're inside the second curly brace, assume it's outPorts
245253
if (secondOpenBraceIndex !== -1 && column > secondOpenBraceIndex) {
246254
// We're inside the `{List of outPorts}` section

0 commit comments

Comments
 (0)