**Description**
When a language port was using Inspector with the "Locator Picker"
feature, it only recognised JavaScript as a language by default. As a
workaround the user was able to click record, interact with the page and
then the language would be correctly used -> csharp e.g. would work in
the "Locator Picker".
**Why?**
Our language bindings are setting `PW_LANG_NAME=<sdkLanguage>` env var
-> good. Our recorder harness also uses this along its internal state
here:
b9b289b641/packages/playwright-core/src/server/recorder.ts (L369)
and it gets used here (no parameter means: we use the first language
aka. primary language):
b9b289b641/packages/playwright-core/src/server/recorder.ts (L95)
The only issue is that the Inspector frontend in the beginning does not
know which language it should use and pass over to the server side, it
then falls back to JavaScript.
**Proposed fix**
Instead of passing it over from the frontend to the server side, we just
always use it from the server side, aka. "currentLanguage". When the
user switches languages in the frontend, "currentLanguage" already gets
updated properly via the "fileChanged" event.
https://github.com/microsoft/playwright-dotnet/issues/2718
---------
Signed-off-by: Max Schmitt <max@schmitt.mx>
Currently, when I choose "Java" in the sources list and then
click on the page to generate the "click" action, sources reset
to "JavaScript". This is very inconvenient.
This changes the logic to only forcefully change files if either
old or new file is a user file, not a generated one.
Use cases considered:
- run `codegen`, click around, choose different language, click more;
- run script with inspector, pause, click "Record" and record an action;
- same as above, but then continue and see that user source is revealed.