Repository: obsidian-tasks-group/obsidian-tasks
Pull request #2889 (2024-06-09 16:33:47)

fix: Restore the original order in Auto Suggestions menu
# Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

Changes visible to users:

- [x] **Bug fix** (prefix: `fix` - non-breaking change which fixes an issue)
  - Issue/discussion: https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2885

## Description

<!--- Remember to provide a general summary of your changes in the Title above -->

<!--- Describe your changes in detail -->
Reverted the Order of Auto Suggest Item too previous Order.
(Just Moved the Task Dependencies Option too the End)

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Fixes https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2885

## How has this been tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

- Manually in the Vault.
- Additonally Tests covering this have been Altered, too the new/old Ordering.

## Screenshots (if appropriate)

## Checklist

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] My code follows the code style of this project and passes `yarn run lint`.
- [ ] My change requires a change to the documentation.
- [ ] I have [updated the documentation](https://publish.obsidian.md/tasks-contributing/Documentation/About+Documentation) accordingly.
- [x] My change has adequate [Unit Test coverage](https://publish.obsidian.md/tasks-contributing/Testing/About+Testing).

## Terms

<!--
By submitting this pull request, you must agree to follow our
[contributing guide](https://publish.obsidian.md/tasks-contributing) and
[Code of Conduct](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/CODE_OF_CONDUCT.md).
Put an x in the boxes to confirm you agree.
-->

- [x] My contribution follows this project's [contributing guide](https://publish.obsidian.md/tasks-contributing)
- [x] I agree to follow this project's [Code of Conduct](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/CODE_OF_CONDUCT.md)


claremacrae: > prefix: refactor - non-breaking change which only improves the design or structure of existing code, and making no changes to its external behaviour

Thanks for this.

I'm not seeing how this is a refactor, as per the quoted description - it does change the external behaviour in that it re-orders menu items.
Genei180: > I'm not seeing how this is a refactor, as per the quoted description - it does change the external behaviour in that it re-orders menu items.

Sorry, out of all the Options, I thought this is the most fitting one.
As it just Moved Part of the Code just a Few Lines Back, for the new ordering.

For my Understanding, it's not a New Feature because
> "non-breaking change which adds functionality"

It doesn't add Functionality in my Eyes, and it's not Really a Bugfix in my Eyes, as well as it doesn't change any Structural/Logical Code that would require a new Test.

The Refractor Keyword states Additionally:
> which only improves the design

(of Code, but in this Case it affects the UI as well) 
So I thought Refractor does fit the Definition of this Pull Request better than Bugfix.

@claremacrae if you want it changed too Bug fix, or Anything else, let me know, and I will Happily Change it.

Thank you for your Time and patience, to review these PRs, and keeping this Great and Helpful Plugin up-to-date.
I highly appreciate it.
claremacrae: Ok thanks, I’ll relabel it then.

Many thanks for the fix!
claremacrae: In manual testing, I can confirm that this does restore the behaviour as of 7.3.0:

![image](https://github.com/obsidian-tasks-group/obsidian-tasks/assets/4840096/1b7ed47d-978b-4d40-9279-ef421b8573d0)


Patch:
diff --git a/src/Suggestor/Suggestor.ts b/src/Suggestor/Suggestor.ts
index 2783d0a5..c8cbcc71 100644
--- a/src/Suggestor/Suggestor.ts
+++ b/src/Suggestor/Suggestor.ts
@@ -149,20 +149,6 @@ function addTaskPropertySuggestions(
             appendText: `${symbols.scheduledDateSymbol} `,
         });
 
-    if (globalThis.SHOW_DEPENDENCY_SUGGESTIONS) {
-        if (!line.includes(symbols.idSymbol))
-            genericSuggestions.push({
-                displayText: `${symbols.idSymbol} id`,
-                appendText: `${symbols.idSymbol}`,
-            });
-
-        if (!line.includes(symbols.dependsOnSymbol))
-            genericSuggestions.push({
-                displayText: `${symbols.dependsOnSymbol} depends on id`,
-                appendText: `${symbols.dependsOnSymbol}`,
-            });
-    }
-
     if (!hasPriority(line)) {
         const prioritySymbols: { [key: string]: string } = symbols.prioritySymbols;
         const priorityTexts = ['High', 'Medium', 'Low', 'Highest', 'Lowest'];
@@ -198,6 +184,20 @@ function addTaskPropertySuggestions(
         });
     }
 
+    if (globalThis.SHOW_DEPENDENCY_SUGGESTIONS) {
+        if (!line.includes(symbols.idSymbol))
+            genericSuggestions.push({
+                displayText: `${symbols.idSymbol} id`,
+                appendText: `${symbols.idSymbol}`,
+            });
+
+        if (!line.includes(symbols.dependsOnSymbol))
+            genericSuggestions.push({
+                displayText: `${symbols.dependsOnSymbol} depends on id`,
+                appendText: `${symbols.dependsOnSymbol}`,
+            });
+    }
+
     // We now filter the general suggestions according to the word at the cursor. If there's
     // something to match, we filter the suggestions accordingly, so the user can get more specific
     // results according to what she's typing.


Test patch:
diff --git a/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_offers_basic_completion_options_for_an_empty_task.approved.json b/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_offers_basic_completion_options_for_an_empty_task.approved.json
index 460b2ec6..dea2870e 100644
--- a/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_offers_basic_completion_options_for_an_empty_task.approved.json
+++ b/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_offers_basic_completion_options_for_an_empty_task.approved.json
@@ -12,16 +12,18 @@
     "appendText": "scheduled:: "
   },
   {
-    "displayText": "id:: id",
-    "appendText": "id::"
+    "displayText": "priority:: high priority",
+    "appendText": "priority:: high] ",
+    "insertSkip": 0
   },
   {
-    "displayText": "dependsOn:: depends on id",
-    "appendText": "dependsOn::"
+    "displayText": "priority:: medium priority",
+    "appendText": "priority:: medium] ",
+    "insertSkip": 0
   },
   {
-    "displayText": "priority:: high priority",
-    "appendText": "priority:: high] ",
+    "displayText": "priority:: low priority",
+    "appendText": "priority:: low] ",
     "insertSkip": 0
   }
 ]
diff --git a/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_show_all_suggested_text.approved.md b/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_show_all_suggested_text.approved.md
index 1828572e..f1182b13 100644
--- a/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_show_all_suggested_text.approved.md
+++ b/tests/Suggestor/Suggestor.test.auto-complete_with__dataview__symbols_show_all_suggested_text.approved.md
@@ -3,8 +3,6 @@
 | due:: due date | due::  |
 | start:: start date | start::  |
 | scheduled:: scheduled date | scheduled::  |
-| id:: id | id:: |
-| dependsOn:: depends on id | dependsOn:: |
 | priority:: high priority | priority:: high]  |
 | priority:: medium priority | priority:: medium]  |
 | priority:: low priority | priority:: low]  |
@@ -12,6 +10,8 @@
 | priority:: lowest priority | priority:: lowest]  |
 | repeat:: recurring (repeat) | repeat::  |
 | created:: created today (2022-07-11) | created:: 2022-07-11]  |
+| id:: id | id:: |
+| dependsOn:: depends on id | dependsOn:: |
 | every | repeat:: every  |
 | every day | repeat:: every day  |
 | every week | repeat:: every week  |
diff --git a/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_offers_basic_completion_options_for_an_empty_task.approved.json b/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_offers_basic_completion_options_for_an_empty_task.approved.json
index 1195cf25..10fe4d6b 100644
--- a/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_offers_basic_completion_options_for_an_empty_task.approved.json
+++ b/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_offers_basic_completion_options_for_an_empty_task.approved.json
@@ -17,11 +17,11 @@
     "appendText": "⏳ "
   },
   {
-    "displayText": "🆔 id",
-    "appendText": "🆔"
+    "displayText": "⏫ high priority",
+    "appendText": "⏫ "
   },
   {
-    "displayText": "⛔ depends on id",
-    "appendText": "⛔"
+    "displayText": "🔼 medium priority",
+    "appendText": "🔼 "
   }
 ]
diff --git a/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_show_all_suggested_text.approved.md b/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_show_all_suggested_text.approved.md
index 4c035a29..3463a71a 100644
--- a/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_show_all_suggested_text.approved.md
+++ b/tests/Suggestor/Suggestor.test.auto-complete_with__emoji__symbols_show_all_suggested_text.approved.md
@@ -4,8 +4,6 @@
 | 📅 due date | 📅  |
 | 🛫 start date | 🛫  |
 | ⏳ scheduled date | ⏳  |
-| 🆔 id | 🆔 |
-| ⛔ depends on id | ⛔ |
 | ⏫ high priority | ⏫  |
 | 🔼 medium priority | 🔼  |
 | 🔽 low priority | 🔽  |
@@ -13,6 +11,8 @@
 | ⏬ lowest priority | ⏬  |
 | 🔁 recurring (repeat) | 🔁  |
 | ➕ created today (2022-07-11) | ➕ 2022-07-11  |
+| 🆔 id | 🆔 |
+| ⛔ depends on id | ⛔ |
 | every | 🔁 every  |
 | every day | 🔁 every day  |
 | every week | 🔁 every week  |