Skip to content

Commit

Permalink
For open diff editors, resolve the underlying original editor to set … (
Browse files Browse the repository at this point in the history
#201597)

* For open diff editors, resolve the underlying original editor to set the appropriate language debugger.

* Get modified editor rather than original.

---------

Co-authored-by: Mahmoud Khalil <[email protected]>
  • Loading branch information
mahmoudsalah1993 and Mahmoud Khalil authored Dec 31, 2023
1 parent 83b909c commit df8db3a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/vs/workbench/contrib/debug/browser/welcomeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { WorkbenchStateContext } from 'vs/workbench/common/contextkeys';
import { OpenFolderAction, OpenFileAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
import { isMacintosh, isWeb } from 'vs/base/common/platform';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { DisposableStore } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -62,7 +62,11 @@ export class WelcomeView extends ViewPane {
this.debugStartLanguageContext.set(lastSetLanguage);

const setContextKey = () => {
const editorControl = this.editorService.activeTextEditorControl;
let editorControl = this.editorService.activeTextEditorControl;
if (isDiffEditor(editorControl)) {
editorControl = editorControl.getModifiedEditor();
}

if (isCodeEditor(editorControl)) {
const model = editorControl.getModel();
const language = model ? model.getLanguageId() : undefined;
Expand All @@ -82,7 +86,11 @@ export class WelcomeView extends ViewPane {
this._register(editorService.onDidActiveEditorChange(() => {
disposables.clear();

const editorControl = this.editorService.activeTextEditorControl;
let editorControl = this.editorService.activeTextEditorControl;
if (isDiffEditor(editorControl)) {
editorControl = editorControl.getModifiedEditor();
}

if (isCodeEditor(editorControl)) {
disposables.add(editorControl.onDidChangeModelLanguage(setContextKey));
}
Expand Down

0 comments on commit df8db3a

Please sign in to comment.