Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ VS Codeのフォーク。本家にはないUI/UX改善を追加した(してい
| `coderm.workbench.editor.resizePaneRight` | ペインを右方向にリサイズ |
| `coderm.workbench.modalEditor.open` | 空のモーダルエディタを開く |
| `coderm.workbench.modalEditor.close` | モーダルエディタを閉じる |
| `coderm.workbench.openReadme` | workspaceルートのREADME.mdを開く(なければ新規ファイル) |

> [!TIP]
> **モーダルエディタ:** モーダルが開いてフォーカスされている間、Quick Open のファイルやエディタ配置のターミナルはモーダル内に直接開きます。モーダル内でターミナル(`lazygit` 等)を動かすには `terminal.integrated.defaultLocation: "editor"` を設定してください(パネルターミナルはモーダルに流入しません)。`coderm.modal.captureContent: false` で、モーダルを閉じてメインへ流す本家挙動に戻せます。
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Settings unique to Coderm that are not available in upstream VS Code.
| `coderm.workbench.editor.resizePaneRight` | Resize pane rightward |
| `coderm.workbench.modalEditor.open` | Open modal editor |
| `coderm.workbench.modalEditor.close` | Close modal editor |
| `coderm.workbench.openReadme` | Open the workspace root's README.md, or create a new untitled file if absent |

> [!TIP]
> **Modal Editor:** While a modal is open and focused, files from Quick Open and editor-targeted terminals open directly inside it. To run a terminal (e.g. `lazygit`) inside the modal, set `terminal.integrated.defaultLocation: "editor"` — panel terminals do not flow into the modal. Set `coderm.modal.captureContent: false` to restore the upstream behavior (closing the modal and redirecting editors to the main area).
Expand Down
2 changes: 1 addition & 1 deletion extensions/copilot/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import './gitWorktreeDefaults.js';
import './hideTitleBarMoreActions.js';
import './inactiveOverlay.js';
import './modalEditorActions.js';
import './openReadme.js';
import './preventNewGroupOnFocus.js';
import './quickOpenIncludeTerminals.js';
import './quickOpenLocalFiles.js';
Expand Down
73 changes: 73 additions & 0 deletions src/vs/workbench/contrib/coderm/browser/openReadme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { localize2 } from '../../../../nls.js';
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { IFileService } from '../../../../platform/files/common/files.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { URI } from '../../../../base/common/uri.js';
import { IEditorService } from '../../../services/editor/common/editorService.js';
import { NEW_UNTITLED_FILE_COMMAND_ID } from '../../files/browser/fileConstants.js';

/**
* Action that opens the workspace root's README.md, falling back to a new
* untitled file when it is absent.
*
* Registered as a command-palette action (`coderm.workbench.openReadme`).
*/
class OpenReadmeAction extends Action2 {
/** Unique command identifier for this action. */
static readonly ID = 'coderm.workbench.openReadme';

constructor() {
super({
id: OpenReadmeAction.ID,
title: localize2('coderm.workbench.openReadme', 'Open README'),
f1: true,
category: Categories.File,
});
}

/**
* Executes the open README action.
*
* Best-effort resolves the first workspace folder's README.md: if present
* it is opened, otherwise the upstream "New Untitled Text File" command is
* invoked.
*
* @param accessor - Service accessor for dependency injection.
*/
override async run(accessor: ServicesAccessor): Promise<void> {
const workspaceContextService = accessor.get(IWorkspaceContextService);
const fileService = accessor.get(IFileService);
const editorService = accessor.get(IEditorService);
const commandService = accessor.get(ICommandService);

// Constraint: only the first workspace folder is consulted to keep
// resolution cheap and predictable; multi-root workspaces do not scan
// every folder (decided trade-off: simplicity over coverage).
const workspaceRoot = workspaceContextService.getWorkspace().folders[0]?.uri;
const readmeUri = workspaceRoot ? URI.joinPath(workspaceRoot, 'README.md') : undefined;

// Why executeCommand instead of re-implementing: delegating to the real
// upstream command means behavior changes (e.g. language/viewType args)
// are tracked for free, and the no-workspace / missing-README cases
// share a single fallback path.
if (!readmeUri || !await fileService.exists(readmeUri)) {
await commandService.executeCommand(NEW_UNTITLED_FILE_COMMAND_ID);
return;
}

await editorService.openEditor({
resource: readmeUri,
options: { pinned: true },
});
}
}

registerAction2(OpenReadmeAction);
Loading