Skip to content

Commit 59c880e

Browse files
committed
remove redundant code
1 parent 95123c3 commit 59c880e

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

src/autocomplete/ResourcePropertyCompletionProvider.ts

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,35 +98,17 @@ export class ResourcePropertyCompletionProvider implements CompletionProvider {
9898
private getSchemaPath(context: Context): string {
9999
let segments = context.propertyPath.slice(3);
100100

101-
// For SYNTHETIC_KEY_OR_VALUE, both key and value need the same path (current property)
101+
// For key completions (except SYNTHETIC_KEY_OR_VALUE), remove last segment
102102
if (
103-
NodeType.isNodeType(context['node'], CommonNodeTypes.SYNTHETIC_KEY_OR_VALUE) ||
104-
(context.isKey() && context.isValue())
103+
context.isKey() &&
104+
segments.length > 0 &&
105+
!NodeType.isNodeType(context['node'], CommonNodeTypes.SYNTHETIC_KEY_OR_VALUE) &&
106+
!(context.isKey() && context.isValue())
105107
) {
106-
const path = templatePathToJsonPointerPath(segments);
107-
return path;
108+
segments = segments.slice(0, -1);
108109
}
109110

110-
// For key completions, we need to determine the correct path
111-
if (context.isKey() && segments.length > 0) {
112-
// Special case: if we're in an array item (last segment is a number),
113-
// keep the full path to get array item schema
114-
const lastSegment = segments[segments.length - 1];
115-
116-
if (typeof lastSegment === 'number' || lastSegment === '') {
117-
segments = segments.slice(0, -1); // Remove the index/empty string
118-
const path = templatePathToJsonPointerPath(segments);
119-
return path;
120-
} else {
121-
// Regular case: remove last segment to get parent properties
122-
segments = segments.slice(0, -1);
123-
const path = templatePathToJsonPointerPath(segments);
124-
return path;
125-
}
126-
}
127-
128-
const finalPath = templatePathToJsonPointerPath(segments);
129-
return finalPath;
111+
return templatePathToJsonPointerPath(segments);
130112
}
131113

132114
/**

0 commit comments

Comments
 (0)