@fresh-editor/fresh-editor 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +10 -0
  3. package/package.json +1 -1
  4. package/plugins/audit_mode.ts +79 -58
  5. package/plugins/check-types.sh +1 -0
  6. package/plugins/clangd-lsp.ts +9 -6
  7. package/plugins/clangd_support.ts +12 -8
  8. package/plugins/code-tour.ts +15 -10
  9. package/plugins/config-schema.json +40 -3
  10. package/plugins/csharp_support.ts +15 -10
  11. package/plugins/css-lsp.ts +9 -6
  12. package/plugins/diagnostics_panel.ts +25 -18
  13. package/plugins/examples/README.md +1 -2
  14. package/plugins/examples/async_demo.ts +28 -28
  15. package/plugins/examples/bookmarks.ts +34 -32
  16. package/plugins/examples/buffer_query_demo.ts +20 -20
  17. package/plugins/examples/hello_world.ts +46 -10
  18. package/plugins/examples/virtual_buffer_demo.ts +16 -12
  19. package/plugins/find_references.ts +7 -5
  20. package/plugins/git_blame.ts +13 -9
  21. package/plugins/git_explorer.ts +9 -6
  22. package/plugins/git_find_file.ts +7 -5
  23. package/plugins/git_grep.ts +3 -2
  24. package/plugins/git_gutter.ts +15 -10
  25. package/plugins/git_log.ts +27 -18
  26. package/plugins/go-lsp.ts +9 -6
  27. package/plugins/html-lsp.ts +9 -6
  28. package/plugins/java-lsp.ts +9 -6
  29. package/plugins/json-lsp.ts +9 -6
  30. package/plugins/latex-lsp.ts +9 -6
  31. package/plugins/lib/finder.ts +1 -0
  32. package/plugins/lib/fresh.d.ts +139 -14
  33. package/plugins/live_grep.ts +3 -2
  34. package/plugins/markdown_compose.ts +33 -23
  35. package/plugins/markdown_source.ts +15 -10
  36. package/plugins/marksman-lsp.ts +9 -6
  37. package/plugins/merge_conflict.ts +33 -22
  38. package/plugins/odin-lsp.ts +9 -6
  39. package/plugins/path_complete.ts +3 -2
  40. package/plugins/pkg.ts +70 -48
  41. package/plugins/python-lsp.ts +9 -6
  42. package/plugins/rust-lsp.ts +102 -6
  43. package/plugins/search_replace.ts +32 -21
  44. package/plugins/templ-lsp.ts +9 -6
  45. package/plugins/test_i18n.ts +3 -2
  46. package/plugins/theme_editor.i18n.json +28 -14
  47. package/plugins/theme_editor.ts +1230 -495
  48. package/plugins/typescript-lsp.ts +9 -6
  49. package/plugins/vi_mode.ts +487 -297
  50. package/plugins/welcome.ts +9 -6
  51. package/plugins/zig-lsp.ts +9 -6
@@ -317,7 +317,7 @@ async function updateGitGutter(bufferId: number): Promise<void> {
317
317
  /**
318
318
  * Handle after file open - initialize git state and update indicators
319
319
  */
320
- globalThis.onGitGutterAfterFileOpen = function (args: {
320
+ function onGitGutterAfterFileOpen(args: {
321
321
  buffer_id: number;
322
322
  path: string;
323
323
  }): boolean {
@@ -339,12 +339,13 @@ globalThis.onGitGutterAfterFileOpen = function (args: {
339
339
  updateGitGutter(bufferId);
340
340
 
341
341
  return true;
342
- };
342
+ }
343
+ registerHandler("onGitGutterAfterFileOpen", onGitGutterAfterFileOpen);
343
344
 
344
345
  /**
345
346
  * Handle buffer activation - update if we have state but indicators might be stale
346
347
  */
347
- globalThis.onGitGutterBufferActivated = function (args: {
348
+ function onGitGutterBufferActivated(args: {
348
349
  buffer_id: number;
349
350
  }): boolean {
350
351
  const bufferId = args.buffer_id;
@@ -365,12 +366,13 @@ globalThis.onGitGutterBufferActivated = function (args: {
365
366
  // (they update on file open and save)
366
367
 
367
368
  return true;
368
- };
369
+ }
370
+ registerHandler("onGitGutterBufferActivated", onGitGutterBufferActivated);
369
371
 
370
372
  /**
371
373
  * Handle after file save - refresh indicators
372
374
  */
373
- globalThis.onGitGutterAfterSave = function (args: {
375
+ function onGitGutterAfterSave(args: {
374
376
  buffer_id: number;
375
377
  path: string;
376
378
  }): boolean {
@@ -392,7 +394,8 @@ globalThis.onGitGutterAfterSave = function (args: {
392
394
  updateGitGutter(bufferId);
393
395
 
394
396
  return true;
395
- };
397
+ }
398
+ registerHandler("onGitGutterAfterSave", onGitGutterAfterSave);
396
399
 
397
400
  // Note: Git diff compares the file on disk, not the in-memory buffer.
398
401
  // Line indicators automatically track position changes via byte-position markers.
@@ -401,12 +404,13 @@ globalThis.onGitGutterAfterSave = function (args: {
401
404
  /**
402
405
  * Handle buffer closed - cleanup state
403
406
  */
404
- globalThis.onGitGutterBufferClosed = function (args: {
407
+ function onGitGutterBufferClosed(args: {
405
408
  buffer_id: number;
406
409
  }): boolean {
407
410
  bufferStates.delete(args.buffer_id);
408
411
  return true;
409
- };
412
+ }
413
+ registerHandler("onGitGutterBufferClosed", onGitGutterBufferClosed);
410
414
 
411
415
  // =============================================================================
412
416
  // Commands
@@ -415,7 +419,7 @@ globalThis.onGitGutterBufferClosed = function (args: {
415
419
  /**
416
420
  * Manually refresh git gutter for the current buffer
417
421
  */
418
- globalThis.git_gutter_refresh = function (): void {
422
+ function git_gutter_refresh() : void {
419
423
  const bufferId = editor.getActiveBufferId();
420
424
  const filePath = editor.getBufferPath(bufferId);
421
425
 
@@ -439,7 +443,8 @@ globalThis.git_gutter_refresh = function (): void {
439
443
  const count = state?.hunks.length || 0;
440
444
  editor.setStatus(editor.t("status.changes", { count: String(count) }));
441
445
  });
442
- };
446
+ }
447
+ registerHandler("git_gutter_refresh", git_gutter_refresh);
443
448
 
444
449
  // =============================================================================
445
450
  // Registration
@@ -628,7 +628,7 @@ function applyCommitDetailHighlighting(): void {
628
628
  // Public Commands - Git Log
629
629
  // =============================================================================
630
630
 
631
- globalThis.show_git_log = async function(): Promise<void> {
631
+ async function show_git_log() : Promise<void> {
632
632
  if (gitLogState.isOpen) {
633
633
  editor.setStatus(editor.t("status.already_open"));
634
634
  return;
@@ -678,9 +678,10 @@ globalThis.show_git_log = async function(): Promise<void> {
678
678
  gitLogState.splitId = null;
679
679
  editor.setStatus(editor.t("status.failed_open"));
680
680
  }
681
- };
681
+ }
682
+ registerHandler("show_git_log", show_git_log);
682
683
 
683
- globalThis.git_log_close = function(): void {
684
+ function git_log_close() : void {
684
685
  if (!gitLogState.isOpen) {
685
686
  return;
686
687
  }
@@ -701,10 +702,11 @@ globalThis.git_log_close = function(): void {
701
702
  gitLogState.sourceBufferId = null;
702
703
  gitLogState.commits = [];
703
704
  editor.setStatus(editor.t("status.closed"));
704
- };
705
+ }
706
+ registerHandler("git_log_close", git_log_close);
705
707
 
706
708
  // Cursor moved handler for git log - update highlighting and status
707
- globalThis.on_git_log_cursor_moved = function(data: {
709
+ function on_git_log_cursor_moved(data: {
708
710
  buffer_id: number;
709
711
  cursor_id: number;
710
712
  old_position: number;
@@ -726,19 +728,21 @@ globalThis.on_git_log_cursor_moved = function(data: {
726
728
  if (commitIndex >= 0 && commitIndex < gitLogState.commits.length) {
727
729
  editor.setStatus(editor.t("status.commit_position", { current: String(commitIndex + 1), total: String(gitLogState.commits.length) }));
728
730
  }
729
- };
731
+ }
732
+ registerHandler("on_git_log_cursor_moved", on_git_log_cursor_moved);
730
733
 
731
734
  // Register cursor movement handler
732
735
  editor.on("cursor_moved", "on_git_log_cursor_moved");
733
736
 
734
- globalThis.git_log_refresh = async function(): Promise<void> {
737
+ async function git_log_refresh() : Promise<void> {
735
738
  if (!gitLogState.isOpen) return;
736
739
 
737
740
  editor.setStatus(editor.t("status.refreshing"));
738
741
  gitLogState.commits = await fetchGitLog();
739
742
  updateGitLogView();
740
743
  editor.setStatus(editor.t("status.refreshed", { count: String(gitLogState.commits.length) }));
741
- };
744
+ }
745
+ registerHandler("git_log_refresh", git_log_refresh);
742
746
 
743
747
  // Helper function to get commit at current cursor position
744
748
  function getCommitAtCursor(): GitCommit | null {
@@ -766,7 +770,7 @@ function getCommitAtCursor(): GitCommit | null {
766
770
  return null;
767
771
  }
768
772
 
769
- globalThis.git_log_show_commit = async function(): Promise<void> {
773
+ async function git_log_show_commit() : Promise<void> {
770
774
  if (!gitLogState.isOpen || gitLogState.commits.length === 0) return;
771
775
  if (gitLogState.splitId === null) return;
772
776
 
@@ -812,9 +816,10 @@ globalThis.git_log_show_commit = async function(): Promise<void> {
812
816
  } else {
813
817
  editor.setStatus(editor.t("status.failed_open_details"));
814
818
  }
815
- };
819
+ }
820
+ registerHandler("git_log_show_commit", git_log_show_commit);
816
821
 
817
- globalThis.git_log_copy_hash = function(): void {
822
+ function git_log_copy_hash() : void {
818
823
  if (!gitLogState.isOpen || gitLogState.commits.length === 0) return;
819
824
 
820
825
  const commit = getCommitAtCursor();
@@ -826,13 +831,14 @@ globalThis.git_log_copy_hash = function(): void {
826
831
  // Copy hash to clipboard
827
832
  editor.copyToClipboard(commit.hash);
828
833
  editor.setStatus(editor.t("status.hash_copied", { short: commit.shortHash, full: commit.hash }));
829
- };
834
+ }
835
+ registerHandler("git_log_copy_hash", git_log_copy_hash);
830
836
 
831
837
  // =============================================================================
832
838
  // Public Commands - Commit Detail
833
839
  // =============================================================================
834
840
 
835
- globalThis.git_commit_detail_close = function(): void {
841
+ function git_commit_detail_close() : void {
836
842
  if (!commitDetailState.isOpen) {
837
843
  return;
838
844
  }
@@ -855,10 +861,11 @@ globalThis.git_commit_detail_close = function(): void {
855
861
  commitDetailState.commit = null;
856
862
 
857
863
  editor.setStatus(editor.t("status.log_ready", { count: String(gitLogState.commits.length) }));
858
- };
864
+ }
865
+ registerHandler("git_commit_detail_close", git_commit_detail_close);
859
866
 
860
867
  // Close file view and go back to commit detail
861
- globalThis.git_file_view_close = function(): void {
868
+ function git_file_view_close() : void {
862
869
  if (!fileViewState.isOpen) {
863
870
  return;
864
871
  }
@@ -884,7 +891,8 @@ globalThis.git_file_view_close = function(): void {
884
891
  if (commitDetailState.commit) {
885
892
  editor.setStatus(editor.t("status.commit_ready", { hash: commitDetailState.commit.shortHash }));
886
893
  }
887
- };
894
+ }
895
+ registerHandler("git_file_view_close", git_file_view_close);
888
896
 
889
897
  // Fetch file content at a specific commit
890
898
  async function fetchFileAtCommit(commitHash: string, filePath: string): Promise<string | null> {
@@ -1074,7 +1082,7 @@ function applyFileViewHighlighting(bufferId: number, content: string, filePath:
1074
1082
  }
1075
1083
 
1076
1084
  // Open file at the current diff line position - shows file as it was at that commit
1077
- globalThis.git_commit_detail_open_file = async function(): Promise<void> {
1085
+ async function git_commit_detail_open_file() : Promise<void> {
1078
1086
  if (!commitDetailState.isOpen || commitDetailState.bufferId === null) {
1079
1087
  return;
1080
1088
  }
@@ -1148,7 +1156,8 @@ globalThis.git_commit_detail_open_file = async function(): Promise<void> {
1148
1156
  } else {
1149
1157
  editor.setStatus(editor.t("status.move_to_diff"));
1150
1158
  }
1151
- };
1159
+ }
1160
+ registerHandler("git_commit_detail_open_file", git_commit_detail_open_file);
1152
1161
 
1153
1162
  // =============================================================================
1154
1163
  // Command Registration
package/plugins/go-lsp.ts CHANGED
@@ -46,7 +46,7 @@ let goLspError: { serverCommand: string; message: string } | null = null;
46
46
  /**
47
47
  * Handle LSP server errors for Go
48
48
  */
49
- globalThis.on_go_lsp_server_error = function (data: LspServerErrorData): void {
49
+ function on_go_lsp_server_error(data: LspServerErrorData) : void {
50
50
  // Only handle Go language errors
51
51
  if (data.language !== "go") {
52
52
  return;
@@ -68,7 +68,8 @@ globalThis.on_go_lsp_server_error = function (data: LspServerErrorData): void {
68
68
  } else {
69
69
  editor.setStatus(`Go LSP error: ${data.message}`);
70
70
  }
71
- };
71
+ }
72
+ registerHandler("on_go_lsp_server_error", on_go_lsp_server_error);
72
73
 
73
74
  // Register hook for LSP server errors
74
75
  editor.on("lsp_server_error", "on_go_lsp_server_error");
@@ -76,7 +77,7 @@ editor.on("lsp_server_error", "on_go_lsp_server_error");
76
77
  /**
77
78
  * Handle status bar click when there's a Go LSP error
78
79
  */
79
- globalThis.on_go_lsp_status_clicked = function (
80
+ function on_go_lsp_status_clicked(
80
81
  data: LspStatusClickedData
81
82
  ): void {
82
83
  // Only handle Go language clicks when there's an error
@@ -97,7 +98,8 @@ globalThis.on_go_lsp_status_clicked = function (
97
98
  { id: "dismiss", label: "Dismiss (ESC)" },
98
99
  ],
99
100
  });
100
- };
101
+ }
102
+ registerHandler("on_go_lsp_status_clicked", on_go_lsp_status_clicked);
101
103
 
102
104
  // Register hook for status bar clicks
103
105
  editor.on("lsp_status_clicked", "on_go_lsp_status_clicked");
@@ -105,7 +107,7 @@ editor.on("lsp_status_clicked", "on_go_lsp_status_clicked");
105
107
  /**
106
108
  * Handle action popup results for Go LSP help
107
109
  */
108
- globalThis.on_go_lsp_action_result = function (
110
+ function on_go_lsp_action_result(
109
111
  data: ActionPopupResultData
110
112
  ): void {
111
113
  // Only handle our popup
@@ -135,7 +137,8 @@ globalThis.on_go_lsp_action_result = function (
135
137
  default:
136
138
  editor.debug(`go-lsp: Unknown action: ${data.action_id}`);
137
139
  }
138
- };
140
+ }
141
+ registerHandler("on_go_lsp_action_result", on_go_lsp_action_result);
139
142
 
140
143
  // Register hook for action popup results
141
144
  editor.on("action_popup_result", "on_go_lsp_action_result");
@@ -46,7 +46,7 @@ let htmlLspError: { serverCommand: string; message: string } | null = null;
46
46
  /**
47
47
  * Handle LSP server errors for HTML
48
48
  */
49
- globalThis.on_html_lsp_server_error = function (
49
+ function on_html_lsp_server_error(
50
50
  data: LspServerErrorData
51
51
  ): void {
52
52
  // Only handle HTML language errors
@@ -70,7 +70,8 @@ globalThis.on_html_lsp_server_error = function (
70
70
  } else {
71
71
  editor.setStatus(`HTML LSP error: ${data.message}`);
72
72
  }
73
- };
73
+ }
74
+ registerHandler("on_html_lsp_server_error", on_html_lsp_server_error);
74
75
 
75
76
  // Register hook for LSP server errors
76
77
  editor.on("lsp_server_error", "on_html_lsp_server_error");
@@ -78,7 +79,7 @@ editor.on("lsp_server_error", "on_html_lsp_server_error");
78
79
  /**
79
80
  * Handle status bar click when there's an HTML LSP error
80
81
  */
81
- globalThis.on_html_lsp_status_clicked = function (
82
+ function on_html_lsp_status_clicked(
82
83
  data: LspStatusClickedData
83
84
  ): void {
84
85
  // Only handle HTML language clicks when there's an error
@@ -99,7 +100,8 @@ globalThis.on_html_lsp_status_clicked = function (
99
100
  { id: "dismiss", label: "Dismiss (ESC)" },
100
101
  ],
101
102
  });
102
- };
103
+ }
104
+ registerHandler("on_html_lsp_status_clicked", on_html_lsp_status_clicked);
103
105
 
104
106
  // Register hook for status bar clicks
105
107
  editor.on("lsp_status_clicked", "on_html_lsp_status_clicked");
@@ -107,7 +109,7 @@ editor.on("lsp_status_clicked", "on_html_lsp_status_clicked");
107
109
  /**
108
110
  * Handle action popup results for HTML LSP help
109
111
  */
110
- globalThis.on_html_lsp_action_result = function (
112
+ function on_html_lsp_action_result(
111
113
  data: ActionPopupResultData
112
114
  ): void {
113
115
  // Only handle our popup
@@ -137,7 +139,8 @@ globalThis.on_html_lsp_action_result = function (
137
139
  default:
138
140
  editor.debug(`html-lsp: Unknown action: ${data.action_id}`);
139
141
  }
140
- };
142
+ }
143
+ registerHandler("on_html_lsp_action_result", on_html_lsp_action_result);
141
144
 
142
145
  // Register hook for action popup results
143
146
  editor.on("action_popup_result", "on_html_lsp_action_result");
@@ -22,7 +22,7 @@ interface ActionPopupResultData {
22
22
  const INSTALL_URL = "https://github.com/eclipse-jdtls/eclipse.jdt.ls#installation";
23
23
  let javaLspError: { serverCommand: string; message: string } | null = null;
24
24
 
25
- globalThis.on_java_lsp_server_error = function (data: LspServerErrorData): void {
25
+ function on_java_lsp_server_error(data: LspServerErrorData) : void {
26
26
  if (data.language !== "java") return;
27
27
  javaLspError = { serverCommand: data.server_command, message: data.message };
28
28
  if (data.error_type === "not_found") {
@@ -30,10 +30,11 @@ globalThis.on_java_lsp_server_error = function (data: LspServerErrorData): void
30
30
  } else {
31
31
  editor.setStatus(`Java LSP error: ${data.message}`);
32
32
  }
33
- };
33
+ }
34
+ registerHandler("on_java_lsp_server_error", on_java_lsp_server_error);
34
35
  editor.on("lsp_server_error", "on_java_lsp_server_error");
35
36
 
36
- globalThis.on_java_lsp_status_clicked = function (data: LspStatusClickedData): void {
37
+ function on_java_lsp_status_clicked(data: LspStatusClickedData) : void {
37
38
  if (data.language !== "java" || !javaLspError) return;
38
39
  editor.showActionPopup({
39
40
  id: "java-lsp-help",
@@ -45,10 +46,11 @@ globalThis.on_java_lsp_status_clicked = function (data: LspStatusClickedData): v
45
46
  { id: "dismiss", label: "Dismiss (ESC)" },
46
47
  ],
47
48
  });
48
- };
49
+ }
50
+ registerHandler("on_java_lsp_status_clicked", on_java_lsp_status_clicked);
49
51
  editor.on("lsp_status_clicked", "on_java_lsp_status_clicked");
50
52
 
51
- globalThis.on_java_lsp_action_result = function (data: ActionPopupResultData): void {
53
+ function on_java_lsp_action_result(data: ActionPopupResultData) : void {
52
54
  if (data.popup_id !== "java-lsp-help") return;
53
55
  switch (data.action_id) {
54
56
  case "copy_url":
@@ -61,5 +63,6 @@ globalThis.on_java_lsp_action_result = function (data: ActionPopupResultData): v
61
63
  javaLspError = null;
62
64
  break;
63
65
  }
64
- };
66
+ }
67
+ registerHandler("on_java_lsp_action_result", on_java_lsp_action_result);
65
68
  editor.on("action_popup_result", "on_java_lsp_action_result");
@@ -46,7 +46,7 @@ let jsonLspError: { serverCommand: string; message: string } | null = null;
46
46
  /**
47
47
  * Handle LSP server errors for JSON
48
48
  */
49
- globalThis.on_json_lsp_server_error = function (
49
+ function on_json_lsp_server_error(
50
50
  data: LspServerErrorData
51
51
  ): void {
52
52
  // Only handle JSON language errors
@@ -70,7 +70,8 @@ globalThis.on_json_lsp_server_error = function (
70
70
  } else {
71
71
  editor.setStatus(`JSON LSP error: ${data.message}`);
72
72
  }
73
- };
73
+ }
74
+ registerHandler("on_json_lsp_server_error", on_json_lsp_server_error);
74
75
 
75
76
  // Register hook for LSP server errors
76
77
  editor.on("lsp_server_error", "on_json_lsp_server_error");
@@ -78,7 +79,7 @@ editor.on("lsp_server_error", "on_json_lsp_server_error");
78
79
  /**
79
80
  * Handle status bar click when there's a JSON LSP error
80
81
  */
81
- globalThis.on_json_lsp_status_clicked = function (
82
+ function on_json_lsp_status_clicked(
82
83
  data: LspStatusClickedData
83
84
  ): void {
84
85
  // Only handle JSON language clicks when there's an error
@@ -99,7 +100,8 @@ globalThis.on_json_lsp_status_clicked = function (
99
100
  { id: "dismiss", label: "Dismiss (ESC)" },
100
101
  ],
101
102
  });
102
- };
103
+ }
104
+ registerHandler("on_json_lsp_status_clicked", on_json_lsp_status_clicked);
103
105
 
104
106
  // Register hook for status bar clicks
105
107
  editor.on("lsp_status_clicked", "on_json_lsp_status_clicked");
@@ -107,7 +109,7 @@ editor.on("lsp_status_clicked", "on_json_lsp_status_clicked");
107
109
  /**
108
110
  * Handle action popup results for JSON LSP help
109
111
  */
110
- globalThis.on_json_lsp_action_result = function (
112
+ function on_json_lsp_action_result(
111
113
  data: ActionPopupResultData
112
114
  ): void {
113
115
  // Only handle our popup
@@ -137,7 +139,8 @@ globalThis.on_json_lsp_action_result = function (
137
139
  default:
138
140
  editor.debug(`json-lsp: Unknown action: ${data.action_id}`);
139
141
  }
140
- };
142
+ }
143
+ registerHandler("on_json_lsp_action_result", on_json_lsp_action_result);
141
144
 
142
145
  // Register hook for action popup results
143
146
  editor.on("action_popup_result", "on_json_lsp_action_result");
@@ -22,7 +22,7 @@ interface ActionPopupResultData {
22
22
  const INSTALL_URL = "https://github.com/latex-lsp/texlab#installation";
23
23
  let latexLspError: { serverCommand: string; message: string } | null = null;
24
24
 
25
- globalThis.on_latex_lsp_server_error = function (data: LspServerErrorData): void {
25
+ function on_latex_lsp_server_error(data: LspServerErrorData) : void {
26
26
  if (data.language !== "latex") return;
27
27
  latexLspError = { serverCommand: data.server_command, message: data.message };
28
28
  if (data.error_type === "not_found") {
@@ -30,10 +30,11 @@ globalThis.on_latex_lsp_server_error = function (data: LspServerErrorData): void
30
30
  } else {
31
31
  editor.setStatus(`LaTeX LSP error: ${data.message}`);
32
32
  }
33
- };
33
+ }
34
+ registerHandler("on_latex_lsp_server_error", on_latex_lsp_server_error);
34
35
  editor.on("lsp_server_error", "on_latex_lsp_server_error");
35
36
 
36
- globalThis.on_latex_lsp_status_clicked = function (data: LspStatusClickedData): void {
37
+ function on_latex_lsp_status_clicked(data: LspStatusClickedData) : void {
37
38
  if (data.language !== "latex" || !latexLspError) return;
38
39
  editor.showActionPopup({
39
40
  id: "latex-lsp-help",
@@ -45,10 +46,11 @@ globalThis.on_latex_lsp_status_clicked = function (data: LspStatusClickedData):
45
46
  { id: "dismiss", label: "Dismiss (ESC)" },
46
47
  ],
47
48
  });
48
- };
49
+ }
50
+ registerHandler("on_latex_lsp_status_clicked", on_latex_lsp_status_clicked);
49
51
  editor.on("lsp_status_clicked", "on_latex_lsp_status_clicked");
50
52
 
51
- globalThis.on_latex_lsp_action_result = function (data: ActionPopupResultData): void {
53
+ function on_latex_lsp_action_result(data: ActionPopupResultData) : void {
52
54
  if (data.popup_id !== "latex-lsp-help") return;
53
55
  switch (data.action_id) {
54
56
  case "copy_url":
@@ -61,5 +63,6 @@ globalThis.on_latex_lsp_action_result = function (data: ActionPopupResultData):
61
63
  latexLspError = null;
62
64
  break;
63
65
  }
64
- };
66
+ }
67
+ registerHandler("on_latex_lsp_action_result", on_latex_lsp_action_result);
65
68
  editor.on("action_popup_result", "on_latex_lsp_action_result");
@@ -883,6 +883,7 @@ export class Finder<T> {
883
883
 
884
884
  try {
885
885
  const content = await this.editor.readFile(entry.location.file);
886
+ if (!content) return;
886
887
  const lines = content.split("\n");
887
888
 
888
889
  const contextLines = this.getContextLines();