-
Notifications
You must be signed in to change notification settings - Fork 1
Fix document manager constructor not updating cached values #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
39fb78b
781ffa5
e7eb170
e011359
d09fafd
08dc41f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,7 @@ export function getTemplateArtifactsHandler( | |
| components.s3Service, | ||
| document.documentType, | ||
| document.uri, | ||
| document.contents(), | ||
| document.contents() ?? '', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be checked at like 92 |
||
| ); | ||
| const artifacts = template.getTemplateArtifacts(); | ||
| return { artifacts }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ export class ResourceStateImporter { | |
| if (insertPosition.replaceEntireFile) { | ||
| // Replace entire file with properly formatted JSON | ||
| snippetText = docFormattedText; | ||
| const endPosition = { line: document.lineCount, character: 0 }; | ||
| const endPosition = { line: document.lineCount ?? 0, character: 0 }; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we exit early if theres no document? |
||
| textEdit = TextEdit.replace(Range.create({ line: 0, character: 0 }, endPosition), snippetText); | ||
| } else { | ||
| // Insert at specific position | ||
|
|
@@ -420,7 +420,7 @@ export class ResourceStateImporter { | |
| : { line: resourcesSection.endPosition.row + 1, character: 0 }; | ||
| } else { | ||
| // Find the last non-empty line | ||
| let lastNonEmptyLine = document.lineCount - 1; | ||
| let lastNonEmptyLine = document.lineCount ? document.lineCount - 1 : 0; | ||
| while (lastNonEmptyLine >= 0 && document.getLine(lastNonEmptyLine)?.trim().length === 0) { | ||
| lastNonEmptyLine--; | ||
| } | ||
|
|
@@ -434,12 +434,25 @@ export class ResourceStateImporter { | |
| }; | ||
| } | ||
|
|
||
| let line = resourcesSection ? resourcesSection.endPosition.row : document.lineCount - 1; | ||
| let line = resourcesSection | ||
| ? resourcesSection.endPosition.row | ||
| : document.lineCount | ||
| ? document.lineCount - 1 | ||
| : 0; | ||
|
|
||
| // For JSON without Resources section, check if file is essentially empty | ||
| if (!resourcesSection) { | ||
| try { | ||
| const parsed = JSON.parse(document.getText()) as Record<string, unknown>; | ||
| const text = document.getText(); | ||
| if (!text) { | ||
| return { | ||
| position: { line: 0, character: 0 }, | ||
| commaPrefixNeeded: false, | ||
| newLineSuffixNeeded: false, | ||
| replaceEntireFile: true, | ||
| }; | ||
| } | ||
| const parsed = JSON.parse(text) as Record<string, unknown>; | ||
| const hasContent = Object.keys(parsed).length > 0; | ||
|
|
||
| // If no content, replace entire file | ||
|
|
@@ -495,7 +508,7 @@ export class ResourceStateImporter { | |
| } | ||
| // malformed case, allow import to end of document | ||
| return { | ||
| position: { line: document.lineCount, character: 0 }, | ||
| position: { line: document.lineCount ?? 0, character: 0 }, | ||
| commaPrefixNeeded: false, | ||
| newLineSuffixNeeded: false, | ||
| replaceEntireFile: false, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,14 +97,22 @@ export async function processChangeSet( | |
| throw new ResponseError(ErrorCodes.InvalidParams, `Document not found: ${params.uri}`); | ||
| } | ||
| let templateBody = document.contents(); | ||
| if (!templateBody) { | ||
| throw new ResponseError(ErrorCodes.InvalidParams, `Document content is undefined: ${params.uri}`); | ||
| } | ||
| let templateS3Url: string | undefined; | ||
| let expectedETag: string | undefined; | ||
| try { | ||
| if (params.s3Bucket) { | ||
| const s3KeyPrefix = params.s3Key?.includes('/') | ||
| ? params.s3Key.slice(0, params.s3Key.lastIndexOf('/')) | ||
| : undefined; | ||
| const template = new ArtifactExporter(s3Service, document.documentType, document.uri, document.contents()); | ||
| const template = new ArtifactExporter( | ||
| s3Service, | ||
| document.documentType, | ||
| document.uri, | ||
| document.contents() ?? '', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably throw at line 100 |
||
| ); | ||
|
|
||
| const exportedTemplate = await template.export(params.s3Bucket, s3KeyPrefix); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sill be true if contents is both
undefinedoremptywhich breaks line 33