Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Go to file): Autotype suggestions typing path #1680

Conversation

chrjorgensen
Copy link
Collaborator

Changes

This pull request is a squashed version of PR #1242 and must be used instead to make a cleaner git history.
The original author @sebCIL is kept on the commit.

@chrjorgensen chrjorgensen added the enhancement New feature or request label Nov 23, 2023
@chrjorgensen chrjorgensen added this to the 2.5.0 release milestone Nov 23, 2023
Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a lot of logic being handled in the wrong file.

I am thinking code-for-ibmi.goToFile (and code-for-ibmi.goToFileReadOnly) should likely go into a separate file.

Secondly, I think we need to be careful about using onDidChangeValue because a fast typing user is resulting in spamming the server. We need to look into using some kind of timeout to slow down the requests to the server.

Something like this perhaps?

quickPick.onDidChangeValue(async () => {
  clearTimeout(timeout);
  timeout = setTimeout(() => {
    // Do something with quickPick.value
  }, 500);
});

@chrjorgensen
Copy link
Collaborator Author

@worksofliam

Secondly, I think we need to be careful about using onDidChangeValue because a fast typing user is resulting in spamming the server. We need to look into using some kind of timeout to slow down the requests to the server.

Ah - I didn't understand your comment until I realized that onDidChangeValue would call the server at any time there was a * in the typed value. This was an error, it was only supposed to call the server when the typed value had a '*' in the end. I have fixed this in commit 574b2bd.

I have also fixed some other small issues - can I make you test it one more time and see if it's better now?

I'm fine with the code being extracted into a separate file - but can we do that in 2.4.1? I will make an issue about this, if you are okay with this.

@chrjorgensen
Copy link
Collaborator Author

@worksofliam Also note that there's a limit of 30 members retrieved from the server, in order to not delay the list unnecessary...

@worksofliam
Copy link
Contributor

@chrjorgensen

I'm fine with the code being extracted into a separate file - but can we do that in 2.4.1? I will make an issue about this, if you are okay with this.

Perfect. Thank you! I will have another review for you today 💯

FROM qsys2.SYSPARTITIONSTAT
WHERE TABLE_SCHEMA = '${selectionSplit[0]}'
AND table_name = '${selectionSplit[1]}'
AND TABLE_PARTITION like '${filterText}%'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider not adding this condition against TABLE_PARTITION when filterText is blank. It's evaluating to: TABLE_PARITION like '%'.

QSYSINC/H/*

FROM QSYS2.SYSTABLES
WHERE TABLE_SCHEMA = '${selectionSplit[0]}'
AND FILE_TYPE = 'S'
AND SYSTEM_TABLE_NAME like '${filterText}%'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here about filterText being blank.

Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally works good. I left some comments about the where clause being used for the filter. I also think we need an improved UX to show that it is loading data, perhaps with something like this before the SQL statements are executed?

                quickPick.items = [
                  {
                    label: 'Searching',
                    alwaysShow: true,
                    description: 'Please wait..',
                  },
                ]

@worksofliam
Copy link
Contributor

worksofliam commented Dec 1, 2023

@chrjorgensen Here is a summary of my changes, which are quite a lot.

  • You can no longer select the 'Loading' indicator
  • Stopped passing in a clause for filterValue if it is empty and limit the results based on the filterValue variable (see maxItems constant)
  • Removed forEach and push combination in place of map on all result sets.
  • Removed the previous caching mechanism due to the fact that I couldn't backtrack my filter, for example:
    1. If I filtered against QSYSINC/MIH/*, it would show me the members for that source file - great!
    2. In the same quick pick, if I change the value to QSYSINC/H/* then nothing would load.
  • Keep the limit to 30 if the filterValue is empty, otherwise the limit is very high as the user is being more precise.
  • After the filter items have loaded, remove the * so the user can filter the filtered items (filter-caption?!?!)

This is obviously a lot of changes, but think I did what you would think is right. If not, I am happy to back out my changes.

@chrjorgensen
Copy link
Collaborator Author

chrjorgensen commented Dec 6, 2023

@worksofliam Your changes worked great - but there were some old errors and other stuff, that I changed:

  • Searching for names with variant characters did not work - fixed.
  • I removed the limit on the SQL (maxItems constant), since it's fast enough even without the limit. 14000+ members were retrieved in approx. 5 seconds on my small test system.
  • The typed value should not be added to the list (a leftover from copying from the Change Current Library function, I guess).
  • I changed the search instruction to be more clear.

Please have a go. If you're pleased with it, let's make the release - we can always fix any small errors later... 😃

@worksofliam
Copy link
Contributor

Ok. This is soooo cool. I love this feature!!! Excellent work @chrjorgensen - thanks for your awesome work on this. Let's merge and I will release.

Things I want to do in the future:

  • Move the source code for this into another .ts file
  • Perhaps if I enter QSYSINC (the library) there can be an option to create a filter from the list

@worksofliam worksofliam merged commit 9b896db into codefori:master Dec 7, 2023
1 check passed
@rbeckham
Copy link
Contributor

rbeckham commented Dec 7, 2023

just got to try this new feature. This is so awesome!!! this was my biggest complaint with Code for i, such a great enhancements. Thanks to all who contributed!

@chrjorgensen chrjorgensen deleted the feature/sebCIL-goToFile_Autotype_suggestions branch March 20, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants