Skip to content

Commit

Permalink
Remove lwfs
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Dec 12, 2023
1 parent 554c181 commit be733a3
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 32 deletions.
21 changes: 0 additions & 21 deletions src/core/file-system.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/language/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class DefinitionProvider implements vscode.DefinitionProvider {
}

provideDefinition(document: vscode.TextDocument, position: vscode.Position): vscode.Location | undefined {
if (lw.lwfs.isVirtualUri(document.uri)) {
if (document.uri.scheme !== 'file') {
return
}
const token = tokenizer(document, position)
Expand Down
3 changes: 1 addition & 2 deletions src/language/symbol-document.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as vscode from 'vscode'
import { lw } from '../lw'
import { TeXElement, TeXElementType } from '../outline/structurelib/types'
import { buildBibTeX } from '../outline/structurelib/bibtex'
import { construct as constructLaTeX } from '../outline/structurelib/latex'
Expand All @@ -13,7 +12,7 @@ export class DocSymbolProvider implements vscode.DocumentSymbolProvider {
} else if (document.languageId === 'doctex') {
return construct(document).then((sections: TeXElement[]) => this.sectionToSymbols(sections))
}
if (lw.lwfs.isVirtualUri(document.uri)) {
if (document.uri.scheme !== 'file') {
return []
}
const sections = await constructLaTeX(document.fileName, false)
Expand Down
2 changes: 0 additions & 2 deletions src/lw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type { Cleaner } from './extras/cleaner'
import type { LaTeXCommanderTreeView } from './extras/activity-bar'
import type { Counter } from './extras/counter'
import type { Linter } from './lint/latex-linter'
import type { LwFileSystem } from './core/file-system'
import type { MathPreviewPanel } from './extras/math-preview-panel'
import type { Section } from './extras/section'
import type { dupLabelDetector } from './lint/duplicate-label'
Expand All @@ -38,7 +37,6 @@ export const lw = {
cache: {} as typeof cache,
root: {} as typeof root,
compile: {} as typeof compile,
lwfs: Object.create(null) as LwFileSystem,
viewer: {} as typeof viewer,
server: {} as typeof server,
locate: {} as typeof locate,
Expand Down
8 changes: 3 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { LaTeXCommanderTreeView } from './extras/activity-bar'
import { Counter } from './extras/counter'
import { dupLabelDetector } from './lint/duplicate-label'
import { Linter } from './lint/latex-linter'
import { LwFileSystem } from './core/file-system'
import { MathPreviewPanel } from './extras/math-preview-panel'
import { Section } from './extras/section'
import { SnippetView } from './extras/snippet-view'
Expand All @@ -57,7 +56,6 @@ const logger = lw.log('Extension')

function initialize(extensionContext: vscode.ExtensionContext) {
lw.onDispose(undefined, extensionContext.subscriptions)
lw.lwfs = new LwFileSystem()
lw.completer = new Completer()
lw.atSuggestionCompleter = new AtSuggestionCompleter()
lw.linter = new Linter()
Expand Down Expand Up @@ -113,7 +111,7 @@ export function activate(extensionContext: vscode.ExtensionContext) {
}))

extensionContext.subscriptions.push(vscode.workspace.onDidSaveTextDocument( (e: vscode.TextDocument) => {
if (lw.lwfs.isVirtualUri(e.uri)){
if (e.uri.scheme !== 'file'){
return
}
if (lw.file.hasTexLangId(e.languageId) ||
Expand Down Expand Up @@ -141,7 +139,7 @@ export function activate(extensionContext: vscode.ExtensionContext) {
} else if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.languageId.toLowerCase() === 'log') {
logger.showStatus()
}
if (e && lw.lwfs.isVirtualUri(e.document.uri)){
if (e && e.document.uri.scheme !== 'file'){
return
}
if (e && lw.file.hasTexLangId(e.document.languageId) && e.document.fileName !== prevTeXDocumentPath) {
Expand All @@ -154,7 +152,7 @@ export function activate(extensionContext: vscode.ExtensionContext) {
}))

extensionContext.subscriptions.push(vscode.workspace.onDidChangeTextDocument((e: vscode.TextDocumentChangeEvent) => {
if (lw.lwfs.isVirtualUri(e.document.uri)){
if (e.document.uri.scheme !== 'file'){
return
}
if (!lw.file.hasTexLangId(e.document.languageId) &&
Expand Down
2 changes: 1 addition & 1 deletion src/preview/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async function handler(request: http.IncomingMessage, response: http.ServerRespo
return
}
try {
const buf: Buffer = await lw.lwfs.readFileAsBuffer(fileUri)
const buf: Buffer = Buffer.from(await vscode.workspace.fs.readFile(fileUri))
sendOkResponse(response, buf, 'application/pdf')
logger.log(`Preview PDF file: ${fileUri.toString(true)}`)
} catch (e) {
Expand Down

0 comments on commit be733a3

Please sign in to comment.