Use buffer's main language when fetching language tasks (cherry-pick #32580) (#32581)

gcp-cherry-pick-bot[bot] and Kirill Bulatov created

Cherry-picked Use buffer's main language when fetching language tasks
(#32580)

Closes https://github.com/zed-industries/zed/issues/32465

Release Notes:

- Fixed language tasks fetched incorrectly for certain selections

Co-authored-by: Kirill Bulatov <kirill@zed.dev>

Change summary

crates/project/src/task_inventory.rs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

Detailed changes

crates/project/src/task_inventory.rs 🔗

@@ -369,8 +369,7 @@ impl Inventory {
     ) {
         let worktree = task_contexts.worktree();
         let location = task_contexts.location();
-        let language = location
-            .and_then(|location| location.buffer.read(cx).language_at(location.range.start));
+        let language = location.and_then(|location| location.buffer.read(cx).language());
         let task_source_kind = language.as_ref().map(|language| TaskSourceKind::Language {
             name: language.name().into(),
         });