Skip to content

Commit

Permalink
Unset source language if source language equals the target language
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenuhrbach committed Dec 20, 2023
1 parent 8230b76 commit 0084ef4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ function createTranslateCommand(param: TranslateCommandParam) {
await configureSettings();
}

const sourceLang = askForSourceLang
? await showSourceLanguageInput()
: state.sourceLanguage
? state.sourceLanguage
: null;
if (askForSourceLang && sourceLang) {
state.sourceLanguage = sourceLang ?? getDefaultSourceLanguage();
}

if (askForTargetLang || !state.targetLanguage) {
const targetLanguage = await showTargetLanguageInput();

Expand All @@ -88,6 +79,19 @@ function createTranslateCommand(param: TranslateCommandParam) {
state.targetLanguage = targetLanguage;
}

const sourceLang = askForSourceLang
? await showSourceLanguageInput()
: state.sourceLanguage
? state.sourceLanguage
: null;
if (askForSourceLang && sourceLang) {
state.sourceLanguage = sourceLang ?? getDefaultSourceLanguage();
}

if (state.targetLanguage === state.sourceLanguage) {
state.sourceLanguage = null;
}

const selections = vscode.window.activeTextEditor?.selections?.filter(selection => !selection.isEmpty);
if (!selections || selections.length === 0) {
return;
Expand Down

0 comments on commit 0084ef4

Please sign in to comment.