mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-25 00:44:48 +01:00
fix: get editor every time
probably way slower but vscode breaks otherwise?
This commit is contained in:
parent
7ff90b8a3b
commit
95b83be800
1 changed files with 4 additions and 3 deletions
|
@ -2,16 +2,17 @@ import * as vscode from 'vscode';
|
||||||
import * as codemp from 'codemp';
|
import * as codemp from 'codemp';
|
||||||
|
|
||||||
class BufferMapper {
|
class BufferMapper {
|
||||||
bufferToEditorMapping: Map<string, vscode.TextEditor> = new Map();
|
bufferToEditorMapping: Map<string, vscode.Uri> = new Map();
|
||||||
editorToBufferMapping: Map<vscode.Uri, string> = new Map();
|
editorToBufferMapping: Map<vscode.Uri, string> = new Map();
|
||||||
|
|
||||||
public register(buffer: string, editor: vscode.TextEditor) {
|
public register(buffer: string, editor: vscode.TextEditor) {
|
||||||
this.bufferToEditorMapping.set(buffer, editor);
|
this.bufferToEditorMapping.set(buffer, editor.document.uri);
|
||||||
this.editorToBufferMapping.set(editor.document.uri, buffer);
|
this.editorToBufferMapping.set(editor.document.uri, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public by_buffer(name: string): vscode.TextEditor | undefined {
|
public by_buffer(name: string): vscode.TextEditor | undefined {
|
||||||
return this.bufferToEditorMapping.get(name);
|
let uri = this.bufferToEditorMapping.get(name);
|
||||||
|
return vscode.window.visibleTextEditors.find((e) => e.document.uri == uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public by_editor(name: vscode.Uri): string | undefined {
|
public by_editor(name: vscode.Uri): string | undefined {
|
||||||
|
|
Loading…
Reference in a new issue