Skip to content

Commit 1b36083

Browse files
authored
[201_95] Disable command mode autocomplete suggestions in macro editor (#2953)
1 parent 8cbcff8 commit 1b36083

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

devel/201_95.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# [201_95] Disable autocomplete options in macro editor
2+
3+
### What
4+
Disabled the autocomplete popup suggestions in the macro editor while keeping the `\` hybrid command mode functional.
5+
6+
### Why
7+
The macro editor is used for source editing of macros. In this context, autocomplete suggestions for macros popup unexpectedly and interfere with typing command names. However, the `\` key itself should still trigger the hybrid command mode `⟨\⟩`. As the search/replace buffers and other auxiliary windows rely on standard autocomplete behavior, the fix must explicitly target only the macro editor buffers.
8+
9+
### How
10+
Modified `src/Edit/Interface/edit_source.cpp`:
11+
12+
Updated `source_complete_try()` to return early when the current buffer (`buf->buf->name`) is identified as a macro editor buffer. The check properly matches `tmfs://aux/macro-editor` or specific `tmfs://aux/edit-*` URLs while explicitly exempting `edit-shortcuts` and `edit-comment` to avoid unintentionally disabling their autocomplete.
13+
14+
```cpp
15+
// Disable autocomplete options in the macro editor
16+
string buf_name= as_string (buf->buf->name);
17+
if ((starts (buf_name, "tmfs://aux/edit-") &&
18+
buf_name != "tmfs://aux/edit-shortcuts" &&
19+
!starts (buf_name, "tmfs://aux/edit-comment")) ||
20+
buf_name == "tmfs://aux/macro-editor") {
21+
return;
22+
}
23+
```
24+
25+
### How to test
26+
1. Open Mogan Editor.
27+
2. Open the macro editor via **Tools → Macros → New macro or Edit macros**.
28+
3. Press the `\` key and begin typing.
29+
4. **Verify**:
30+
- The `⟨\⟩` bracketed tag (hybrid command mode) appears correctly.
31+
- *No* autocomplete suggestion popup appears while typing.
32+
5. Test in a normal document:
33+
- **Verify**: The `\` key triggers the hybrid command mode completely, and autocomplete functions as normal.
34+
6. Test in search/replace window:
35+
- **Verify**: The `\` key triggers the hybrid command mode completely, and autocomplete functions as normal.

src/Edit/Interface/edit_source.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "merge_sort.hpp"
1919
#include "observers.hpp"
2020
#include "preferences.hpp"
21+
#include "tm_buffer.hpp"
2122
#include "tree_observer.hpp"
2223

2324
#include <moebius/data/scheme.hpp>
@@ -30,6 +31,16 @@ void
3031
edit_interface_rep::source_complete_try () {
3132
bool is_source = (get_env_string ("mode") == "src");
3233
bool is_source_mode= (get_env_string ("preamble") == "true");
34+
35+
// Disable autocomplete options in the macro editor
36+
string buf_name= as_string (buf->buf->name);
37+
if ((starts (buf_name, "tmfs://aux/edit-") &&
38+
buf_name != "tmfs://aux/edit-shortcuts" &&
39+
!starts (buf_name, "tmfs://aux/edit-comment")) ||
40+
buf_name == "tmfs://aux/macro-editor") {
41+
return;
42+
}
43+
3344
if (is_source && (!is_source_mode)) {
3445
completion_style= get_preference ("completion style");
3546
if (completion_style != "popup") {

0 commit comments

Comments
 (0)