Skip to content
35 changes: 35 additions & 0 deletions devel/201_95.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# [201_95] Disable autocomplete options in macro editor

### What
Disabled the autocomplete popup suggestions in the macro editor while keeping the `\` hybrid command mode functional.

### Why
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.

### How
Modified `src/Edit/Interface/edit_source.cpp`:

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.

```cpp
// Disable autocomplete options in the macro editor
string buf_name= as_string (buf->buf->name);
if ((starts (buf_name, "tmfs://aux/edit-") &&
buf_name != "tmfs://aux/edit-shortcuts" &&
!starts (buf_name, "tmfs://aux/edit-comment")) ||
buf_name == "tmfs://aux/macro-editor") {
return;
}
```

### How to test
1. Open Mogan Editor.
2. Open the macro editor via **Tools → Macros → New macro or Edit macros**.
3. Press the `\` key and begin typing.
4. **Verify**:
- The `⟨\⟩` bracketed tag (hybrid command mode) appears correctly.
- *No* autocomplete suggestion popup appears while typing.
5. Test in a normal document:
- **Verify**: The `\` key triggers the hybrid command mode completely, and autocomplete functions as normal.
6. Test in search/replace window:
- **Verify**: The `\` key triggers the hybrid command mode completely, and autocomplete functions as normal.
11 changes: 11 additions & 0 deletions src/Edit/Interface/edit_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "merge_sort.hpp"
#include "observers.hpp"
#include "preferences.hpp"
#include "tm_buffer.hpp"
#include "tree_observer.hpp"

#include <moebius/data/scheme.hpp>
Expand All @@ -30,6 +31,16 @@ void
edit_interface_rep::source_complete_try () {
bool is_source = (get_env_string ("mode") == "src");
bool is_source_mode= (get_env_string ("preamble") == "true");

// Disable autocomplete options in the macro editor
string buf_name= as_string (buf->buf->name);
if ((starts (buf_name, "tmfs://aux/edit-") &&
buf_name != "tmfs://aux/edit-shortcuts" &&
!starts (buf_name, "tmfs://aux/edit-comment")) ||
buf_name == "tmfs://aux/macro-editor") {
return;
}

if (is_source && (!is_source_mode)) {
completion_style= get_preference ("completion style");
if (completion_style != "popup") {
Expand Down