We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
"phones that" should DTRT and select the current word if nothing is selected
there's really no need for both `phones that` and `phones word`, we can just make `phones that` do the right thing and select the current word if nothing is selected - ie. if `edit.selected_text()` returns the empty string?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `core/homophones/homophones.py`
Content:
```
1 import os
2 
3 from talon import Context, Module, actions, app, clip, fs, imgui, ui
4 
5 ########################################################################
6 # global settings
7 ########################################################################
8 
9 # a list of homophones where each line is a comma separated list
10 # e.g. where,wear,ware
11 # a suitable one can be found here:
12 # https://github.com/pimentel/homophones
13 cwd = os.path.dirname(os.path.realpath(__file__))
14 homophones_file = os.path.join(cwd, "homophones.csv")
15 # if quick_replace, then when a word is selected and only one homophone exists,
16 # replace it without bringing up the options
17 quick_replace = True
18 show_help = False
19 ########################################################################
20 
21 ctx = Context()
22 mod = Module()
23 mod.mode("homophones")
24 mod.list("homophones_canonicals", desc="list of words ")
25 
26 main_screen = ui.main_screen()
27 
28 
29 def update_homophones(name, flags):
30     if name != homophones_file:
31         return
32 
33     phones = {}
34     canonical_list = []
35     with open(homophones_file) as f:
36         for line in f:
37             words = line.rstrip().split(",")
38             canonical_list.append(words[0])
39             merged_words = set(words)
40             for word in words:
41                 old_words = phones.get(word.lower(), [])
42                 merged_words.update(old_words)
43             merged_words = sorted(merged_words)
44             for word in merged_words:
45                 phones[word.lower()] = merged_words
46 
47     global all_homophones
48     all_homophones = phones
49     ctx.lists["self.homophones_canonicals"] = canonical_list
50 
51 
52 update_homophones(homophones_file, None)
53 fs.watch(cwd, update_homophones)
54 active_word_list = None
55 is_selection = False
56 
57 
58 def close_homophones():
59     gui.hide()
60     actions.mode.disable("user.homophones")
61 
62 
63 PHONES_FORMATTERS = [
64     lambda word: word.capitalize(),
65     lambda word: word.upper(),
66 ]
67 
68 
69 def find_matching_format_function(word_with_formatting, format_functions):
70     """Finds the formatter function from a list of formatter functions which transforms a word into itself.
71     Returns an identity function if none exists"""
72     for formatter in format_functions:
73         formatted_word = formatter(word_with_formatting)
74         if word_with_formatting == formatted_word:
75             return formatter
76 
77     return lambda word: word
78 
79 
80 def raise_homophones(word_to_find_homophones_for, forced=False, selection=False):
81     global quick_replace
82     global active_word_list
83     global show_help
84     global force_raise
85     global is_selection
86 
87     force_raise = forced
88     is_selection = selection
89 
90     if is_selection:
91         word_to_find_homophones_for = word_to_find_homophones_for.strip()
92 
93     formatter = find_matching_format_function(
94         word_to_find_homophones_for, PHONES_FORMATTERS
95     )
96 
97     word_to_find_homophones_for = word_to_find_homophones_for.lower()
98 
99     # We support plurals, but very naively. If we can't find your word but your word ends in an s, presume its plural
100     # and attempt to find the singular, then present the presumed plurals back. This could be improved!
101     if word_to_find_homophones_for in all_homophones:
102         valid_homophones = all_homophones[word_to_find_homophones_for]
103     elif (
104         word_to_find_homophones_for[-1] == "s"
105         and word_to_find_homophones_for[:-1] in all_homophones
106     ):
107         valid_homophones = map(
108             lambda w: w + "s", all_homophones[word_to_find_homophones_for[:-1]]
109         )
110     else:
111         app.notify(
112             "homophones.py", f'"{word_to_find_homophones_for}" not in homophones list'
113         )
114         return
115 
116     # Move current word to end of list to reduce searcher's cognitive load
117     valid_homophones_reordered = list(
118         filter(
119             lambda word_from_list: word_from_list.lower()
120             != word_to_find_homophones_for,
121             valid_homophones,
122         )
123     ) + [word_to_find_homophones_for]
124     active_word_list = list(map(formatter, valid_homophones_reordered))
125 
126     if (
127         is_selection
128         and len(active_word_list) == 2
129         and quick_replace
130         and not force_raise
131     ):
132         if word_to_find_homophones_for == active_word_list[0].lower():
133             new = active_word_list[1]
134         else:
135             new = active_word_list[0]
136 
137         clip.set(new)
138         actions.edit.paste()
139 
140         return
141 
142     actions.mode.enable("user.homophones")
143     show_help = False
144     gui.show()
145 
146 
147 @imgui.open(x=main_screen.x + main_screen.width / 2.6, y=main_screen.y)
148 def gui(gui: imgui.GUI):
149     global active_word_list
150     if show_help:
151         gui.text("Homephone help - todo")
152     else:
153         gui.text("Select a homophone")
154         gui.line()
155         index = 1
156         for word in active_word_list:
157             if gui.button(f"Choose {index}: {word}"):
158                 actions.insert(actions.user.homophones_select(index))
159                 actions.user.homophones_hide()
160             index = index + 1
161 
162         if gui.button("Phones hide"):
163             actions.user.homophones_hide()
164 
165 
166 def show_help_gui():
167     global show_help
168     show_help = True
169     gui.show()
170 
171 
172 @mod.capture(rule="{self.homophones_canonicals}")
173 def homophones_canonical(m) -> str:
174     "Returns a single string"
175     return m.homophones_canonicals
176 
177 
178 @mod.action_class
179 class Actions:
180     def homophones_hide():
181         """Hides the homophones display"""
182         close_homophones()
183 
184     def homophones_show(m: str):
185         """Show the homophones display"""
186         raise_homophones(m, False, False)
187 
188     def homophones_show_selection():
189         """Show the homophones display for the selected text"""
190         raise_homophones(actions.edit.selected_text(), False, True)
191 
192     def homophones_force_show(m: str):
193         """Show the homophones display forcibly"""
194         raise_homophones(m, True, False)
195 
196     def homophones_force_show_selection():
197         """Show the homophones display for the selected text forcibly"""
198         raise_homophones(actions.edit.selected_text(), True, True)
199 
200     def homophones_select(number: int) -> str:
201         """selects the homophone by number"""
202         if number <= len(active_word_list) and number > 0:
203             return active_word_list[number - 1]
204 
205         error = "homophones.py index {} is out of range (1-{})".format(
206             number, len(active_word_list)
207         )
208         app.notify(error)
209         raise error
210 
211     def homophones_get(word: str) -> [str] or None:
212         """Get homophones for the given word"""
213         word = word.lower()
214         if word in all_homophones:
215             return all_homophones[word]
216         return None
217
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/core/homophones/homophones.py b/core/homophones/homophones.py
--- a/core/homophones/homophones.py
+++ b/core/homophones/homophones.py
@@ -185,6 +185,15 @@
         """Show the homophones display"""
         raise_homophones(m, False, False)
 
+    def homophones_show_auto():
+        """Show homophones for selection, or current word if selection is empty."""
+        text = actions.edit.selected_text()
+        if text:
+            actions.user.homophones_show(text)
+        else:
+            actions.edit.select_word()
+            actions.user.homophones_show_selection()
+
     def homophones_show_selection():
         """Show the homophones display for the selected text"""
         raise_homophones(actions.edit.selected_text(), False, True)

{"golden_diff": "diff --git a/core/homophones/homophones.py b/core/homophones/homophones.py\n--- a/core/homophones/homophones.py\n+++ b/core/homophones/homophones.py\n@@ -185,6 +185,15 @@\n         \"\"\"Show the homophones display\"\"\"\n         raise_homophones(m, False, False)\n \n+    def homophones_show_auto():\n+        \"\"\"Show homophones for selection, or current word if selection is empty.\"\"\"\n+        text = actions.edit.selected_text()\n+        if text:\n+            actions.user.homophones_show(text)\n+        else:\n+            actions.edit.select_word()\n+            actions.user.homophones_show_selection()\n+\n     def homophones_show_selection():\n         \"\"\"Show the homophones display for the selected text\"\"\"\n         raise_homophones(actions.edit.selected_text(), False, True)\n", "issue": "\"phones that\" should DTRT and select the current word if nothing is selected\nthere's really no need for both `phones that` and `phones word`, we can just make `phones that` do the right thing and select the current word if nothing is selected - ie. if `edit.selected_text()` returns the empty string?\n", "before_files": [{"content": "import os\n\nfrom talon import Context, Module, actions, app, clip, fs, imgui, ui\n\n########################################################################\n# global settings\n########################################################################\n\n# a list of homophones where each line is a comma separated list\n# e.g. where,wear,ware\n# a suitable one can be found here:\n# https://github.com/pimentel/homophones\ncwd = os.path.dirname(os.path.realpath(__file__))\nhomophones_file = os.path.join(cwd, \"homophones.csv\")\n# if quick_replace, then when a word is selected and only one homophone exists,\n# replace it without bringing up the options\nquick_replace = True\nshow_help = False\n########################################################################\n\nctx = Context()\nmod = Module()\nmod.mode(\"homophones\")\nmod.list(\"homophones_canonicals\", desc=\"list of words \")\n\nmain_screen = ui.main_screen()\n\n\ndef update_homophones(name, flags):\n    if name != homophones_file:\n        return\n\n    phones = {}\n    canonical_list = []\n    with open(homophones_file) as f:\n        for line in f:\n            words = line.rstrip().split(\",\")\n            canonical_list.append(words[0])\n            merged_words = set(words)\n            for word in words:\n                old_words = phones.get(word.lower(), [])\n                merged_words.update(old_words)\n            merged_words = sorted(merged_words)\n            for word in merged_words:\n                phones[word.lower()] = merged_words\n\n    global all_homophones\n    all_homophones = phones\n    ctx.lists[\"self.homophones_canonicals\"] = canonical_list\n\n\nupdate_homophones(homophones_file, None)\nfs.watch(cwd, update_homophones)\nactive_word_list = None\nis_selection = False\n\n\ndef close_homophones():\n    gui.hide()\n    actions.mode.disable(\"user.homophones\")\n\n\nPHONES_FORMATTERS = [\n    lambda word: word.capitalize(),\n    lambda word: word.upper(),\n]\n\n\ndef find_matching_format_function(word_with_formatting, format_functions):\n    \"\"\"Finds the formatter function from a list of formatter functions which transforms a word into itself.\n    Returns an identity function if none exists\"\"\"\n    for formatter in format_functions:\n        formatted_word = formatter(word_with_formatting)\n        if word_with_formatting == formatted_word:\n            return formatter\n\n    return lambda word: word\n\n\ndef raise_homophones(word_to_find_homophones_for, forced=False, selection=False):\n    global quick_replace\n    global active_word_list\n    global show_help\n    global force_raise\n    global is_selection\n\n    force_raise = forced\n    is_selection = selection\n\n    if is_selection:\n        word_to_find_homophones_for = word_to_find_homophones_for.strip()\n\n    formatter = find_matching_format_function(\n        word_to_find_homophones_for, PHONES_FORMATTERS\n    )\n\n    word_to_find_homophones_for = word_to_find_homophones_for.lower()\n\n    # We support plurals, but very naively. If we can't find your word but your word ends in an s, presume its plural\n    # and attempt to find the singular, then present the presumed plurals back. This could be improved!\n    if word_to_find_homophones_for in all_homophones:\n        valid_homophones = all_homophones[word_to_find_homophones_for]\n    elif (\n        word_to_find_homophones_for[-1] == \"s\"\n        and word_to_find_homophones_for[:-1] in all_homophones\n    ):\n        valid_homophones = map(\n            lambda w: w + \"s\", all_homophones[word_to_find_homophones_for[:-1]]\n        )\n    else:\n        app.notify(\n            \"homophones.py\", f'\"{word_to_find_homophones_for}\" not in homophones list'\n        )\n        return\n\n    # Move current word to end of list to reduce searcher's cognitive load\n    valid_homophones_reordered = list(\n        filter(\n            lambda word_from_list: word_from_list.lower()\n            != word_to_find_homophones_for,\n            valid_homophones,\n        )\n    ) + [word_to_find_homophones_for]\n    active_word_list = list(map(formatter, valid_homophones_reordered))\n\n    if (\n        is_selection\n        and len(active_word_list) == 2\n        and quick_replace\n        and not force_raise\n    ):\n        if word_to_find_homophones_for == active_word_list[0].lower():\n            new = active_word_list[1]\n        else:\n            new = active_word_list[0]\n\n        clip.set(new)\n        actions.edit.paste()\n\n        return\n\n    actions.mode.enable(\"user.homophones\")\n    show_help = False\n    gui.show()\n\n\n@imgui.open(x=main_screen.x + main_screen.width / 2.6, y=main_screen.y)\ndef gui(gui: imgui.GUI):\n    global active_word_list\n    if show_help:\n        gui.text(\"Homephone help - todo\")\n    else:\n        gui.text(\"Select a homophone\")\n        gui.line()\n        index = 1\n        for word in active_word_list:\n            if gui.button(f\"Choose {index}: {word}\"):\n                actions.insert(actions.user.homophones_select(index))\n                actions.user.homophones_hide()\n            index = index + 1\n\n        if gui.button(\"Phones hide\"):\n            actions.user.homophones_hide()\n\n\ndef show_help_gui():\n    global show_help\n    show_help = True\n    gui.show()\n\n\n@mod.capture(rule=\"{self.homophones_canonicals}\")\ndef homophones_canonical(m) -> str:\n    \"Returns a single string\"\n    return m.homophones_canonicals\n\n\n@mod.action_class\nclass Actions:\n    def homophones_hide():\n        \"\"\"Hides the homophones display\"\"\"\n        close_homophones()\n\n    def homophones_show(m: str):\n        \"\"\"Show the homophones display\"\"\"\n        raise_homophones(m, False, False)\n\n    def homophones_show_selection():\n        \"\"\"Show the homophones display for the selected text\"\"\"\n        raise_homophones(actions.edit.selected_text(), False, True)\n\n    def homophones_force_show(m: str):\n        \"\"\"Show the homophones display forcibly\"\"\"\n        raise_homophones(m, True, False)\n\n    def homophones_force_show_selection():\n        \"\"\"Show the homophones display for the selected text forcibly\"\"\"\n        raise_homophones(actions.edit.selected_text(), True, True)\n\n    def homophones_select(number: int) -> str:\n        \"\"\"selects the homophone by number\"\"\"\n        if number <= len(active_word_list) and number > 0:\n            return active_word_list[number - 1]\n\n        error = \"homophones.py index {} is out of range (1-{})\".format(\n            number, len(active_word_list)\n        )\n        app.notify(error)\n        raise error\n\n    def homophones_get(word: str) -> [str] or None:\n        \"\"\"Get homophones for the given word\"\"\"\n        word = word.lower()\n        if word in all_homophones:\n            return all_homophones[word]\n        return None\n", "path": "core/homophones/homophones.py"}], "after_files": [{"content": "import os\n\nfrom talon import Context, Module, actions, app, clip, fs, imgui, ui\n\n########################################################################\n# global settings\n########################################################################\n\n# a list of homophones where each line is a comma separated list\n# e.g. where,wear,ware\n# a suitable one can be found here:\n# https://github.com/pimentel/homophones\ncwd = os.path.dirname(os.path.realpath(__file__))\nhomophones_file = os.path.join(cwd, \"homophones.csv\")\n# if quick_replace, then when a word is selected and only one homophone exists,\n# replace it without bringing up the options\nquick_replace = True\nshow_help = False\n########################################################################\n\nctx = Context()\nmod = Module()\nmod.mode(\"homophones\")\nmod.list(\"homophones_canonicals\", desc=\"list of words \")\n\nmain_screen = ui.main_screen()\n\n\ndef update_homophones(name, flags):\n    if name != homophones_file:\n        return\n\n    phones = {}\n    canonical_list = []\n    with open(homophones_file) as f:\n        for line in f:\n            words = line.rstrip().split(\",\")\n            canonical_list.append(words[0])\n            merged_words = set(words)\n            for word in words:\n                old_words = phones.get(word.lower(), [])\n                merged_words.update(old_words)\n            merged_words = sorted(merged_words)\n            for word in merged_words:\n                phones[word.lower()] = merged_words\n\n    global all_homophones\n    all_homophones = phones\n    ctx.lists[\"self.homophones_canonicals\"] = canonical_list\n\n\nupdate_homophones(homophones_file, None)\nfs.watch(cwd, update_homophones)\nactive_word_list = None\nis_selection = False\n\n\ndef close_homophones():\n    gui.hide()\n    actions.mode.disable(\"user.homophones\")\n\n\nPHONES_FORMATTERS = [\n    lambda word: word.capitalize(),\n    lambda word: word.upper(),\n]\n\n\ndef find_matching_format_function(word_with_formatting, format_functions):\n    \"\"\"Finds the formatter function from a list of formatter functions which transforms a word into itself.\n    Returns an identity function if none exists\"\"\"\n    for formatter in format_functions:\n        formatted_word = formatter(word_with_formatting)\n        if word_with_formatting == formatted_word:\n            return formatter\n\n    return lambda word: word\n\n\ndef raise_homophones(word_to_find_homophones_for, forced=False, selection=False):\n    global quick_replace\n    global active_word_list\n    global show_help\n    global force_raise\n    global is_selection\n\n    force_raise = forced\n    is_selection = selection\n\n    if is_selection:\n        word_to_find_homophones_for = word_to_find_homophones_for.strip()\n\n    formatter = find_matching_format_function(\n        word_to_find_homophones_for, PHONES_FORMATTERS\n    )\n\n    word_to_find_homophones_for = word_to_find_homophones_for.lower()\n\n    # We support plurals, but very naively. If we can't find your word but your word ends in an s, presume its plural\n    # and attempt to find the singular, then present the presumed plurals back. This could be improved!\n    if word_to_find_homophones_for in all_homophones:\n        valid_homophones = all_homophones[word_to_find_homophones_for]\n    elif (\n        word_to_find_homophones_for[-1] == \"s\"\n        and word_to_find_homophones_for[:-1] in all_homophones\n    ):\n        valid_homophones = map(\n            lambda w: w + \"s\", all_homophones[word_to_find_homophones_for[:-1]]\n        )\n    else:\n        app.notify(\n            \"homophones.py\", f'\"{word_to_find_homophones_for}\" not in homophones list'\n        )\n        return\n\n    # Move current word to end of list to reduce searcher's cognitive load\n    valid_homophones_reordered = list(\n        filter(\n            lambda word_from_list: word_from_list.lower()\n            != word_to_find_homophones_for,\n            valid_homophones,\n        )\n    ) + [word_to_find_homophones_for]\n    active_word_list = list(map(formatter, valid_homophones_reordered))\n\n    if (\n        is_selection\n        and len(active_word_list) == 2\n        and quick_replace\n        and not force_raise\n    ):\n        if word_to_find_homophones_for == active_word_list[0].lower():\n            new = active_word_list[1]\n        else:\n            new = active_word_list[0]\n\n        clip.set(new)\n        actions.edit.paste()\n\n        return\n\n    actions.mode.enable(\"user.homophones\")\n    show_help = False\n    gui.show()\n\n\n@imgui.open(x=main_screen.x + main_screen.width / 2.6, y=main_screen.y)\ndef gui(gui: imgui.GUI):\n    global active_word_list\n    if show_help:\n        gui.text(\"Homephone help - todo\")\n    else:\n        gui.text(\"Select a homophone\")\n        gui.line()\n        index = 1\n        for word in active_word_list:\n            if gui.button(f\"Choose {index}: {word}\"):\n                actions.insert(actions.user.homophones_select(index))\n                actions.user.homophones_hide()\n            index = index + 1\n\n        if gui.button(\"Phones hide\"):\n            actions.user.homophones_hide()\n\n\ndef show_help_gui():\n    global show_help\n    show_help = True\n    gui.show()\n\n\n@mod.capture(rule=\"{self.homophones_canonicals}\")\ndef homophones_canonical(m) -> str:\n    \"Returns a single string\"\n    return m.homophones_canonicals\n\n\n@mod.action_class\nclass Actions:\n    def homophones_hide():\n        \"\"\"Hides the homophones display\"\"\"\n        close_homophones()\n\n    def homophones_show(m: str):\n        \"\"\"Show the homophones display\"\"\"\n        raise_homophones(m, False, False)\n\n    def homophones_show_auto():\n        \"\"\"Show homophones for selection, or current word if selection is empty.\"\"\"\n        text = actions.edit.selected_text()\n        if text:\n            actions.user.homophones_show(text)\n        else:\n            actions.edit.select_word()\n            actions.user.homophones_show_selection()\n\n    def homophones_show_selection():\n        \"\"\"Show the homophones display for the selected text\"\"\"\n        raise_homophones(actions.edit.selected_text(), False, True)\n\n    def homophones_force_show(m: str):\n        \"\"\"Show the homophones display forcibly\"\"\"\n        raise_homophones(m, True, False)\n\n    def homophones_force_show_selection():\n        \"\"\"Show the homophones display for the selected text forcibly\"\"\"\n        raise_homophones(actions.edit.selected_text(), True, True)\n\n    def homophones_select(number: int) -> str:\n        \"\"\"selects the homophone by number\"\"\"\n        if number <= len(active_word_list) and number > 0:\n            return active_word_list[number - 1]\n\n        error = \"homophones.py index {} is out of range (1-{})\".format(\n            number, len(active_word_list)\n        )\n        app.notify(error)\n        raise error\n\n    def homophones_get(word: str) -> [str] or None:\n        \"\"\"Get homophones for the given word\"\"\"\n        word = word.lower()\n        if word in all_homophones:\n            return all_homophones[word]\n        return None\n", "path": "core/homophones/homophones.py"}]}