-
Notifications
You must be signed in to change notification settings - Fork 409
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
fix: create new query command opens soql builder #3091
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3091 +/- ##
========================================
Coverage 76.20% 76.21%
========================================
Files 276 276
Lines 10512 10513 +1
Branches 1235 1235
========================================
+ Hits 8011 8012 +1
Misses 2157 2157
Partials 344 344
Continue to review full report at Codecov.
|
@@ -20,9 +20,5 @@ export async function soqlBuilderToggle(doc: vscode.Uri): Promise<void> { | |||
? BUILDER_VIEW_TYPE | |||
: EDITOR_VIEW_TYPE; | |||
|
|||
vscode.commands.executeCommand( | |||
OPEN_WITH_COMMAND, | |||
vscode.Uri.file(doc.fsPath), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this just produces a Uri, which is what doc
already is. So I just use that as is since the openWith command takes a Uri.
const fileName = 'untitled.soql'; | ||
const newUri = vscode.Uri.file(fileName).with({ | ||
scheme: 'untitled', | ||
path: fileName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ultimately, the Uri for an untitled file ends up looking like untitled:untitled.soql
instead of when the file is on disc, which is a file:
scheme.
@@ -21,8 +21,6 @@ describe('soqlOpenNew should', () => { | |||
beforeEach(() => { | |||
sb = createSandbox(); | |||
telemetryStub = sb.stub(telemetryService, 'sendCommandEvent') as SinonStub; | |||
editorOpened = sb.stub(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no longer called, since we do not interact with the openTextDocument() api. Therefore, removed from test and associated expectations.
expect(executeCommandSpy.getCall(0).args[2]).contains(BUILDER_VIEW_TYPE); | ||
expect(executeCommandSpy.getCall(0).args[1].scheme).contains('untitled'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify the untitled scheme is used
@@ -69,7 +69,9 @@ | |||
"papaparse": "^5.3.0", | |||
"sinon": "7.5.0", | |||
"typescript": "3.8.3", | |||
"vscode-languageclient": "6.1.3" | |||
"vscode-languageclient": "6.1.3", | |||
"webpack": "4.30.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this, we can't actually run npm run compile
from within the packages/salesforcedx-vscode-soql
directory. which is a huge time saver.
This matches the version in the top level package.json. However, does anyone think i should just wildcard this? I think that would allow the version to stay in sync with the top level package.
7e36727
to
06769ae
Compare
@@ -145,7 +147,7 @@ | |||
], | |||
"editor/title": [ | |||
{ | |||
"when": "resourceLangId == soql", | |||
"when": "resourceLangId == soql && resourceScheme == file", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toggling from the text editor to the soql builder with an unsaved file causes this issue shown below. By checking the resourceScheme, we just don't show the toggle icon until the file is saved. Which prevents users from toggling back and forth and getting into this situation. Once saved, toggle works as expected.
create-new-toggle-bug.mov
const doc = await vscode.workspace.openTextDocument({ | ||
language: 'soql', | ||
content: '' | ||
const fileName = 'untitled.soql'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I run the "Create Query in SOQL..." command a second time before saving, nothing happens. I guess it is because it is always the same filename here.
If we are OK with this behavior, fine. If not, you might want to extract that hard-coded filename into a function to generate a unique file for the current workspace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I messed with this a bit, and the behavior of untitled files with Custom Editors even with a numeric file sequence is not any better. Check out this movie. I'm a little dumbfounded...and ignorant still about much of the vscode OS along with the behavior of Custom Editors. If i use the openTextDocument() api, then the Save As doesn't behave as we expect.
create-query-numbering.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I say we go out with this behavior and see what people think. At least we are functioning again.
Tricky stuff! Thanks for the explanations. So, to make sure I understand: Would this not be a problem if the "customEditors" selector supported "languageId" (instead of file extension) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Just double-check the observation about the uniqueness of the generated filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Yes. And it does kinda seem like a flaw in their design. |
Co-authored-by: Jonny Hork <[email protected]>
Co-authored-by: Jonny Hork <[email protected]> Co-authored-by: Jonny Hork <[email protected]>
What does this PR do?
With the last update of VSCode ( Version: 1.54.3 ), behavior around opening a new empty soql query command changed. Digging into this, i discovered we were probably riding on top of a bug that got fixed or a loop-hole that got closed. This PR fixes the issue.
Nitty Gritty Details
CustomEditors are associated with a filename pattern and not a languageId.
Previously, when we created a new untitled file for a soql query, we did not specify a file name that matched our filenamePattern, but rather just specified a languageId like this:
Yet, user's were still previously presented with a Soql Builder ui. Unfortunately, this stopped working in Version: 1.54.3.
This fix addresses that issue and honors the filenamePattern by naming the untitled file
untitled.soql
, as well as uses the specialuntitled
scheme, which let's vscode know that the file has no title and is not in the file system ( until the user elects to save it ). There's a lot of discussion on this issue here.Additionally, I discovered that the toggle feature requires a file on disk, and so the toggle feature does not present in the editor menu until the file is saved ( see the new when condition addition ). This also matches the existing behavior, so there is no functional change to the UX, as the toggle editor menu would not appear until the file was saved.
What issues does this PR fix or reference?
@W-8990594@
Functionality Before
create-new-bug.mov
Functionality After
create-new-fix.mov