Always issue a new completions request when typing a trigger character

Nathan Sobo created

We'll interpolate the anchor range of original request, but it's still a good idea to be up-to-date in case the language server is influenced by the content preceding the location. This doesn't *seem* to be the case with rust-analyzer so far, but it's how VS Code works so let's do it this way.

Change summary

crates/editor/src/editor.rs | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

Detailed changes

crates/editor/src/editor.rs 🔗

@@ -1390,15 +1390,13 @@ impl Editor {
     }
 
     fn trigger_completion_on_input(&mut self, text: &str, cx: &mut ViewContext<Self>) {
-        if self.completion_state.is_none() {
-            if let Some(selection) = self.newest_anchor_selection() {
-                if self
-                    .buffer
-                    .read(cx)
-                    .is_completion_trigger(selection.head(), text, cx)
-                {
-                    self.show_completions(&ShowCompletions, cx);
-                }
+        if let Some(selection) = self.newest_anchor_selection() {
+            if self
+                .buffer
+                .read(cx)
+                .is_completion_trigger(selection.head(), text, cx)
+            {
+                self.show_completions(&ShowCompletions, cx);
             }
         }
     }