Skip to content

Commit

Permalink
fix: Improved editor responsiveness by only reprocessing changed file…
Browse files Browse the repository at this point in the history
…s upon certain trigger characters
  • Loading branch information
adam-coster committed Jul 24, 2023
1 parent 088296a commit 81afa8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 21 additions & 0 deletions packages/vscode/src/extension.provider.mts
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,31 @@ export class StitchProvider
if (doc.languageId !== 'gml') {
return;
}

// Only reprocess on trigger characters, since autocompletes are the most sensitive to changes.
if (
'contentChanges' in event &&
event.contentChanges.length === 1 &&
event.contentChanges[0].text.length
) {
const isTriggerCharacter = [
...completionTriggerCharacters,
' ',
'\r\n',
'\n',
';',
',',
].includes(event.contentChanges[0].text as any);
if (!isTriggerCharacter) {
return;
}
}

if (this.provider.processingFiles.has(doc.uri.fsPath)) {
logger.info('Already processing file', doc.uri.fsPath);
return;
}

this.provider.diagnosticCollection.delete(doc.uri);
// Add the processing promise to a map so
// that other functionality can wait for it
Expand Down
1 change: 0 additions & 1 deletion packages/vscode/src/inspector.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ObjectParentFolder extends StitchTreeItemBase<'inspector-object-parents'>

onSetParent(parent: Asset<'objects'> | undefined) {
this.provider.onUpdate(this);
this.provider.view.reveal(this, { expand: true });
}
}

Expand Down

0 comments on commit 81afa8e

Please sign in to comment.