Skip to content

Commit

Permalink
clean up file-is.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Dec 3, 2023
1 parent 78a368e commit d53630d
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/file-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@ export abstract class FileIO {
abstract insertLine(lineNumber: number, text: string): Promise<void>;
abstract getLine(lineNumber: number): Promise<string>;
abstract getRange(position: Pos): Promise<string>;
/**
* Check if the line at `lineNumber` can be safely overwritten.
* It was necessary for sure before, but I'm not sure if it is now,
* because now the JSON metadata of theorem callouts are hidden by a view plugin.
* I'll check it later.
* @param lineNumber
*/
abstract isSafe(lineNumber: number): boolean;

async getBlockTextFromID(blockID: string, cache?: CachedMetadata): Promise<string | undefined> {
cache = cache ?? this.plugin.app.metadataCache.getFileCache(this.file) ?? undefined;
if (cache) {
const sectionCache = cache.sections?.find(
(sectionCache) => sectionCache.id == blockID
);
const position = sectionCache?.position;
if (position) {
return await this.getRange(position);
}
}
}
}


Expand Down Expand Up @@ -71,11 +50,6 @@ export class ActiveNoteIO extends FileIO {
const text = this.editor.getRange(from, to);
return text;
}

isSafe(lineNumber: number): boolean {
const cursorPos = this.editor.getCursor();
return cursorPos.line != lineNumber;
}
}


Expand All @@ -90,10 +64,6 @@ export class NonActiveNoteIO extends FileIO {
super(plugin, file);
}

async getData(): Promise<string> {
return this._data ?? (this._data = await this.plugin.app.vault.cachedRead(this.file));
}

async setLine(lineNumber: number, text: string): Promise<void> {
this.plugin.app.vault.process(this.file, (data: string): string => {
const lines = splitIntoLines(data);
Expand Down Expand Up @@ -126,10 +96,6 @@ export class NonActiveNoteIO extends FileIO {
const content = await this.plugin.app.vault.cachedRead(this.file);
return content.slice(position.start.offset, position.end.offset);
}

isSafe(lineNumber: number): boolean {
return true;
}
}


Expand Down

0 comments on commit d53630d

Please sign in to comment.