···11+---
22+'@0no-co/graphqlsp': patch
33+---
44+55+Check the `dirty` state of the file an additional time to prevent writing to the file when the user types directly after saving
+15-4
src/index.ts
···2626import { Cursor } from './cursor';
2727import { loadSchema } from './getSchema';
2828import { getToken } from './token';
2929-import { findAllTaggedTemplateNodes, findNode, getSource } from './utils';
2929+import {
3030+ findAllTaggedTemplateNodes,
3131+ findNode,
3232+ getSource,
3333+ isFileDirty,
3434+} from './utils';
3035import { resolveTemplate } from './resolve';
3136import { generateTypedDocumentNodes } from './types/generate';
3237···174179 const nameParts = name.split('.');
175180 nameParts[nameParts.length - 1] = 'generated.ts';
176181 parts[parts.length - 1] = nameParts.join('.');
177177- const contents = fs.readFileSync(filename, 'utf-8');
178178- const currentText = source.getFullText();
179182180180- if (contents !== currentText) {
183183+ if (isFileDirty(filename, source)) {
181184 return [...newDiagnostics, ...originalDiagnostics];
182185 }
183186···187190 texts.join('\n'),
188191 scalars
189192 ).then(() => {
193193+ if (isFileDirty(filename, source)) {
194194+ return;
195195+ }
196196+190197 nodes.forEach((node, i) => {
191198 const queryText = texts[i] || '';
192199 const parsed = parse(queryText);
···222229 const typeImport = parentChildren.find(x =>
223230 isImportTypeNode(x)
224231 ) as ImportTypeNode;
232232+225233 if (typeImport && typeImport.getText().includes(exportName)) return;
226234227235 const span = { length: 1, start: node.end };
236236+237237+ // TODO: if we have a typeImport but the name has been updated/is wrong
238238+ // we need to leave the "as x" typecast
228239 const text =
229240 source.text.substring(0, span.start) +
230241 imp +