Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Sep 6, 2023
1 parent f2cb635 commit cfe2bf0
Showing 1 changed file with 24 additions and 33 deletions.
57 changes: 24 additions & 33 deletions src/languageFeatures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type languages } from 'monaco-editor/esm/vs/editor/editor.api.js'
import {
fromFoldingRangeContext,
fromMarkerData,
fromPosition,
fromRange,
Expand Down Expand Up @@ -47,22 +46,20 @@ export function createCompletionItemProvider(
async provideCompletionItems(model, position) {
const resource = model.uri

const wordInfo = model.getWordUntilPosition(position)
const worker = await getWorker(resource)
const info = await worker.doComplete(String(resource), fromPosition(position))
if (!info) {
return
}

const wordInfo = model.getWordUntilPosition(position)

return toCompletionList(info, {
range: {
startLineNumber: position.lineNumber,
startColumn: wordInfo.startColumn,
endLineNumber: position.lineNumber,
endColumn: wordInfo.endColumn
}
})
if (info) {
return toCompletionList(info, {
range: {
startLineNumber: position.lineNumber,
startColumn: wordInfo.startColumn,
endLineNumber: position.lineNumber,
endColumn: wordInfo.endColumn
}
})
}
}
}
}
Expand All @@ -87,11 +84,10 @@ export function createHoverProvider(getWorker: WorkerAccessor): languages.HoverP

const worker = await getWorker(resource)
const info = await worker.doHover(String(resource), fromPosition(position))
if (!info) {
return
}

return toHover(info)
if (info) {
return toHover(info)
}
}
}
}
Expand Down Expand Up @@ -134,12 +130,10 @@ export function createLinkProvider(getWorker: WorkerAccessor): languages.LinkPro
const worker = await getWorker(resource)
const links = await worker.findLinks(String(resource))

if (!links) {
return
}

return {
links: links.map(toLink)
if (links) {
return {
links: links.map(toLink)
}
}
}
}
Expand All @@ -157,14 +151,12 @@ export function createCodeActionProvider(getWorker: WorkerAccessor): languages.C
context.markers.map(fromMarkerData)
)

if (!codeActions) {
return
}

return {
actions: codeActions.map((codeAction) => toCodeAction(codeAction)),
dispose() {
// This is required by the TypeScript interface, but it’s not implemented.
if (codeActions) {
return {
actions: codeActions.map((codeAction) => toCodeAction(codeAction)),
dispose() {
// This is required by the TypeScript interface, but it’s not implemented.
}
}
}
}
Expand All @@ -180,7 +172,6 @@ export function createFoldingRangeProvider(

const worker = await getWorker(resource)
const foldingRanges = await worker.getFoldingRanges(String(resource))
console.log(foldingRanges)

return foldingRanges?.map(toFoldingRange)
}
Expand Down

0 comments on commit cfe2bf0

Please sign in to comment.