Skip to content

Commit

Permalink
fix: force update vue source file before format
Browse files Browse the repository at this point in the history
close #1840, close #1842, close #1843
  • Loading branch information
johnsoncodehk committed Sep 7, 2022
1 parent ce2be82 commit da19999
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Expand Up @@ -23,11 +23,11 @@ export function register(context: DocumentServiceRuntimeContext) {
range = vscode.Range.create(document.positionAt(0), document.positionAt(document.getText().length));
}

const vueDocument = context.getAndUpdateVueDocument(document);
const originalDocument = document;
const rootEdits = onTypeParams
? await tryFormat(document, onTypeParams.position, undefined, onTypeParams.ch)
: await tryFormat(document, range, undefined);
const vueDocument = context.getVueDocument(document);

if (!vueDocument)
return rootEdits;
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-language-service/src/documentService.ts
Expand Up @@ -72,7 +72,7 @@ export function getDocumentService(

const context: DocumentServiceRuntimeContext = {
typescript: ts,
getVueDocument,
getAndUpdateVueDocument,
getPlugins() {
return [
...customPlugins,
Expand Down Expand Up @@ -105,7 +105,7 @@ export function getDocumentService(
doAutoInsert: autoInsert.register(context),
};

function getVueDocument(document: TextDocument) {
function getAndUpdateVueDocument(document: TextDocument) {

let vueDoc = vueDocuments.get(document);

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/src/types.ts
Expand Up @@ -6,7 +6,7 @@ import { VueDocument, VueDocuments } from './vueDocuments';

export interface DocumentServiceRuntimeContext {
typescript: typeof import('typescript/lib/tsserverlibrary');
getVueDocument(document: TextDocument): VueDocument | undefined;
getAndUpdateVueDocument(document: TextDocument): VueDocument | undefined;
getPlugins(): EmbeddedLanguageServicePlugin[];
updateTsLs(document: TextDocument): void;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/src/utils/featureWorkers.ts
Expand Up @@ -35,7 +35,7 @@ export async function documentArgFeatureWorker<T, K>(
combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>,
) {

const vueDocument = context.getVueDocument(document);
const vueDocument = context.getAndUpdateVueDocument(document);

let results: NonNullable<Awaited<T>>[] = [];

Expand Down

0 comments on commit da19999

Please sign in to comment.