дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-27 21:12:34 +02:00
Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
08d87c3903 | ||
|
|
1652866769 | ||
|
|
be5a6f62ad |
No files matched your search
Створено
+26
-26
@@ -3962,7 +3962,7 @@ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ide-analysis"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ast-grep-core",
|
||||
"ide-core",
|
||||
@@ -3976,7 +3976,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-build"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
@@ -3991,7 +3991,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-core"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"serde",
|
||||
@@ -4003,7 +4003,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-coverage"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4017,7 +4017,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-dap"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-jsonrpc",
|
||||
@@ -4034,7 +4034,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-db"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"futures",
|
||||
@@ -4054,7 +4054,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-docker"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4067,7 +4067,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-github"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vcs",
|
||||
@@ -4081,7 +4081,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-http"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4099,7 +4099,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-index"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4121,7 +4121,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jsonrpc"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"ide-core",
|
||||
@@ -4136,7 +4136,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-language"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4188,7 +4188,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-lsp"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"globset",
|
||||
@@ -4211,7 +4211,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-plugin"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4229,7 +4229,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-profiler"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4242,7 +4242,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-run"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"ide-core",
|
||||
@@ -4260,7 +4260,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-sdk"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"ide-core",
|
||||
@@ -4277,7 +4277,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-search"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"globset",
|
||||
@@ -4296,7 +4296,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-syntax"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4311,7 +4311,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-terminal"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4324,7 +4324,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-text"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4336,7 +4336,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-tools"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hex",
|
||||
@@ -4356,7 +4356,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vcs"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"gix",
|
||||
@@ -4373,7 +4373,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vfs"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"dunce",
|
||||
@@ -4393,7 +4393,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-workspace"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -5817,7 +5817,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openidea"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ resolver = "3"
|
||||
members = ["crates/*", "src-tauri"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
license = "Apache-2.0"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "openidea",
|
||||
"private": true,
|
||||
"description": "An open-source IDE inspired by IntelliJ IDEA",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.8",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "OpenIDEA",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.8",
|
||||
"identifier": "ai.l0ng.openidea",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/** The line-number gutter's context menu, IDEA's EditorGutterPopupMenu. */
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { menuGroupItems } from "@/workbench/contributions";
|
||||
import type { MenuItem } from "@/ui";
|
||||
import type { EditorSlot } from "./model/slot";
|
||||
|
||||
/** Whether a right-click on `target` belongs to the gutter menu (contributed gutters with their own menu handle theirs). */
|
||||
export function inGutterMenuArea(target: EventTarget | null): boolean {
|
||||
const t = target as HTMLElement | null;
|
||||
return !!t?.closest?.(".cm-gutters") && !t.closest(".cm-vcs-blame");
|
||||
}
|
||||
|
||||
async function setEditorSetting(key: string, value: unknown) {
|
||||
useProject.setState({ settings: await call(commands.settingsSet("global", `editor.${key}`, JSON.stringify(value))) });
|
||||
}
|
||||
|
||||
function toggle(label: string, key: string, on: boolean): MenuItem {
|
||||
return { label, checked: on, run: () => void setEditorSetting(key, !on) };
|
||||
}
|
||||
|
||||
function appearanceItems(): MenuItem[] {
|
||||
const p = editorPrefs();
|
||||
const whitespace = !!useProject.getState().settings?.editor?.showWhitespace;
|
||||
return [
|
||||
toggle("Show Line Numbers", "appearance.lineNumbers", p.appearance.lineNumbers),
|
||||
toggle("Show Gutter Icons", "showGutterIcons", p.showGutterIcons),
|
||||
toggle("Show Folding Outline", "folding.showOutline", p.folding.showOutline),
|
||||
toggle("Show Indent Guides", "appearance.indentGuides", p.appearance.indentGuides),
|
||||
toggle("Show Whitespaces", "showWhitespace", whitespace),
|
||||
toggle("Show Method Separators", "appearance.methodSeparators", p.appearance.methodSeparators),
|
||||
toggle("Show Breadcrumbs", "breadcrumbs.show", p.breadcrumbs.show),
|
||||
];
|
||||
}
|
||||
|
||||
const openSettings = (page: string) => () => void executeAction("file.settings", page);
|
||||
|
||||
export function gutterMenuItems(slot: EditorSlot, line: number): MenuItem[] {
|
||||
const model = slot.model;
|
||||
return [
|
||||
// Contributed groups (Annotate with Git Blame, bookmarks), each followed by a separator.
|
||||
...menuGroupItems("editorGutter", { paths: [model.path], text: slot.currentState().doc.toString(), line }),
|
||||
{ label: "Soft-Wrap", checked: model.softWrapOn(), run: () => model.toggleSoftWrap() },
|
||||
{ label: "Configure Soft Wraps…", run: openSettings("editor.general") },
|
||||
{ kind: "separator" },
|
||||
{ label: "Appearance", submenu: appearanceItems() },
|
||||
{ label: "Configure Gutter Icons…", run: openSettings("editor.general.gutterIcons") },
|
||||
];
|
||||
}
|
||||
@@ -17,9 +17,11 @@ import {
|
||||
type ChangeSet,
|
||||
type TransactionSpec,
|
||||
} from "@codemirror/state";
|
||||
import { EditorView, keymap, type ViewUpdate } from "@codemirror/view";
|
||||
import { EditorView, ViewPlugin, keymap, type ViewUpdate } from "@codemirror/view";
|
||||
import { _addEditor, _removeEditor, documentSynced, isExternalChange, type EditorDocContext, type TextEditorHandle } from "@/editor/api";
|
||||
import { showContextMenu } from "@/ui";
|
||||
import { baseExtensions, compartments, contributionExtensions } from "../cm/setup";
|
||||
import { gutterMenuItems, inGutterMenuArea } from "../gutterMenu";
|
||||
import type { DocModel } from "./document";
|
||||
|
||||
export interface SlotHost {
|
||||
@@ -107,6 +109,18 @@ export class EditorSlot {
|
||||
return true;
|
||||
},
|
||||
}),
|
||||
ViewPlugin.define((view) => {
|
||||
// Gutters sit outside the content DOM. Gutter extensions with their own menu (breakpoints,
|
||||
// annotations) handle the event first and prevent its default.
|
||||
const onContextMenu = (e: MouseEvent) => {
|
||||
if (e.defaultPrevented || !inGutterMenuArea(e.target)) return;
|
||||
e.preventDefault();
|
||||
const block = view.lineBlockAtHeight(e.clientY - view.documentTop);
|
||||
showContextMenu(e, gutterMenuItems(this, view.state.doc.lineAt(block.from).number - 1));
|
||||
};
|
||||
view.dom.addEventListener("contextmenu", onContextMenu);
|
||||
return { destroy: () => view.dom.removeEventListener("contextmenu", onContextMenu) };
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
import { RangeSet, StateEffect, StateField, type EditorState, type Extension } from "@codemirror/state";
|
||||
import { Decoration, EditorView, GutterMarker, ViewPlugin, lineNumberMarkers, type ViewUpdate } from "@codemirror/view";
|
||||
import { editorsFor, mirroredChange, remoteChange, useEditorRegistry, type EditorDocContext } from "@/editor/api";
|
||||
import { showContextMenu } from "@/ui";
|
||||
import { isConditional, mapLines, type BreakpointEntry, type BreakpointStatus } from "../breakpoints/model";
|
||||
import {
|
||||
addBreakpoint,
|
||||
breakpointsOf,
|
||||
setFileBreakpoints,
|
||||
toggleTemporaryBreakpoint,
|
||||
updateBreakpoint,
|
||||
useBreakpoints,
|
||||
} from "../breakpoints/store";
|
||||
@@ -21,14 +19,11 @@ import {
|
||||
removeSpecial,
|
||||
setSpecialLines,
|
||||
specialAt,
|
||||
toggleFieldAt,
|
||||
toggleMethodAt,
|
||||
updateSpecial,
|
||||
useSpecialBreakpoints,
|
||||
type SpecialBreakpoint,
|
||||
} from "../breakpoints/special";
|
||||
import { toggleBreakpointSmart } from "../breakpoints/toggle";
|
||||
import { methodAt, fieldAt } from "../breakpoints/symbols";
|
||||
import { sessionsRunning, useDebug } from "../state";
|
||||
import { openBreakpointPopover } from "../ui/popoverStore";
|
||||
import styles from "./editor.module.css";
|
||||
@@ -172,7 +167,8 @@ export function breakpointGutter(ctx: EditorDocContext): Extension {
|
||||
}),
|
||||
];
|
||||
view.dom.addEventListener("mousedown", this.onMouseDown);
|
||||
view.dom.addEventListener("contextmenu", this.onContextMenu);
|
||||
// Inside view.dom, so this runs before the editor's gutter menu listener there.
|
||||
view.scrollDOM.addEventListener("contextmenu", this.onContextMenu);
|
||||
}
|
||||
|
||||
scheduleRebuild() {
|
||||
@@ -234,59 +230,18 @@ export function breakpointGutter(ctx: EditorDocContext): Extension {
|
||||
if (!inBreakpointArea(e)) return;
|
||||
const line = lineAtEvent(this.view, e);
|
||||
if (line == null) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const at = { x: e.clientX, y: e.clientY };
|
||||
// Other lines get the editor's gutter menu, like IDEA.
|
||||
const bp = specialAt(path).find((b) => b.line === line) ?? breakpointsOf(path).find((b) => b.line === line);
|
||||
if (bp) {
|
||||
openBreakpointPopover(path, bp.id, at);
|
||||
return;
|
||||
}
|
||||
if (!canPlaceBreakpoint(ctx.language)) return;
|
||||
const text = this.view.state.doc.toString();
|
||||
const method = methodAt(ctx.language, text, line);
|
||||
const field = fieldAt(ctx.language, text, line);
|
||||
showContextMenu(at, [
|
||||
{ label: "Toggle Line Breakpoint", icon: "breakpoint", run: () => addBreakpoint(path, line) },
|
||||
{
|
||||
label: "Toggle Temporary Line Breakpoint",
|
||||
icon: "breakpoint",
|
||||
run: () => toggleTemporaryBreakpoint(path, line),
|
||||
},
|
||||
...(method
|
||||
? [
|
||||
{
|
||||
label: `Toggle Method Breakpoint (${method.label})`,
|
||||
icon: "breakpoint-method",
|
||||
run: () => void toggleMethodAt(path, line, method.name),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(field
|
||||
? [
|
||||
{
|
||||
label: `Toggle Field Watchpoint (${field.label})`,
|
||||
icon: "breakpoint-field",
|
||||
run: () => void toggleFieldAt(path, line, field),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: "Add Conditional Breakpoint…",
|
||||
run: () => openBreakpointPopover(path, addBreakpoint(path, line).id, at),
|
||||
},
|
||||
{
|
||||
label: "Add Logpoint…",
|
||||
run: () => openBreakpointPopover(path, addBreakpoint(path, line).id, at, true),
|
||||
},
|
||||
]);
|
||||
if (!bp) return;
|
||||
e.preventDefault();
|
||||
openBreakpointPopover(path, bp.id, { x: e.clientX, y: e.clientY });
|
||||
};
|
||||
|
||||
destroy() {
|
||||
this.destroyed = true;
|
||||
this.unsubs.forEach((u) => u());
|
||||
this.view.dom.removeEventListener("mousedown", this.onMouseDown);
|
||||
this.view.dom.removeEventListener("contextmenu", this.onContextMenu);
|
||||
this.view.scrollDOM.removeEventListener("contextmenu", this.onContextMenu);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
*/
|
||||
import { lazyComponent } from "@/ui";
|
||||
import { activeEditor, registerEditorContribution } from "@/editor/api";
|
||||
import { registerActions } from "@/platform/actions";
|
||||
import { executeAction, registerActions } from "@/platform/actions";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { onIdeEvent } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { registerOverlay, registerToolWindow } from "@/workbench/contributions";
|
||||
import { registerMenuGroup, registerOverlay, registerToolWindow } from "@/workbench/contributions";
|
||||
import { bookmarkGutter } from "./bookmarks/gutter";
|
||||
import {
|
||||
hasBookmark,
|
||||
loadBookmarks,
|
||||
renameBookmarks,
|
||||
toggleBookmark,
|
||||
@@ -46,7 +48,8 @@ function closeAllPopups(except?: PopupKind) {
|
||||
if (except !== "everywhere") hideSearchEverywhere();
|
||||
if (except !== "recent") hideRecentPopup();
|
||||
if (except !== "find") hideFindPopup();
|
||||
if (except !== "fileStructure" && useFileStructurePopup.getState().open) useFileStructurePopup.setState({ open: false });
|
||||
if (except !== "fileStructure" && useFileStructurePopup.getState().open)
|
||||
useFileStructurePopup.setState({ open: false });
|
||||
}
|
||||
|
||||
function jumpBookmark(dir: 1 | -1) {
|
||||
@@ -59,7 +62,9 @@ function jumpBookmark(dir: 1 | -1) {
|
||||
const cur = `${path ?? ""}\u0000${String(line).padStart(9, "0")}`;
|
||||
const sorted = order.sort((a, b) => (a.k < b.k ? -1 : a.k > b.k ? 1 : 0));
|
||||
const next =
|
||||
dir === 1 ? (sorted.find((x) => x.k > cur) ?? sorted[0]) : ([...sorted].reverse().find((x) => x.k < cur) ?? sorted[sorted.length - 1]);
|
||||
dir === 1
|
||||
? (sorted.find((x) => x.k > cur) ?? sorted[0])
|
||||
: ([...sorted].reverse().find((x) => x.k < cur) ?? sorted[sorted.length - 1]);
|
||||
if (next) void openLocation(next.b.path, { line: next.b.line, col: 0 });
|
||||
}
|
||||
|
||||
@@ -113,6 +118,22 @@ export function activate(): void | (() => void) {
|
||||
order: 50,
|
||||
extensions: (ctx) => bookmarkGutter(ctx.path),
|
||||
}),
|
||||
registerMenuGroup({
|
||||
id: "search.bookmarks",
|
||||
menus: ["editorGutter"],
|
||||
order: 20,
|
||||
items: (_menu, { paths: [path], line }) => {
|
||||
if (!path || line == null) return [];
|
||||
const on = hasBookmark(useBookmarks.getState().items, path, line);
|
||||
return [
|
||||
{
|
||||
label: on ? "Remove Bookmark" : "Add Bookmark",
|
||||
shortcut: shortcutLabel("navigate.toggleBookmark"),
|
||||
run: () => void executeAction("navigate.toggleBookmark", { path, line }),
|
||||
},
|
||||
];
|
||||
},
|
||||
}),
|
||||
|
||||
registerActions([
|
||||
{
|
||||
@@ -298,7 +319,8 @@ export function activate(): void | (() => void) {
|
||||
onProject(s.project?.root ?? null);
|
||||
resetTracking();
|
||||
// A directory scope pointed into the previous project.
|
||||
if (useFindPopup.getState().scopeTab === "directory") useFindPopup.setState({ scopeTab: "project", directory: "" });
|
||||
if (useFindPopup.getState().scopeTab === "directory")
|
||||
useFindPopup.setState({ scopeTab: "project", directory: "" });
|
||||
}),
|
||||
onIdeEvent("fsChanged", (e) => {
|
||||
if (!e.removed.length) return;
|
||||
|
||||
@@ -4,21 +4,23 @@
|
||||
* merge and Local History editors, remote operations.
|
||||
*/
|
||||
import { onWorkflowSettingsChange, workflowSettings } from "@/platform/workflowSettings";
|
||||
import { registerEditorContribution } from "@/editor/api";
|
||||
import { editorsFor, registerEditorContribution } from "@/editor/api";
|
||||
import {
|
||||
notifications,
|
||||
registerEditorKind,
|
||||
registerMenuGroup,
|
||||
registerOverlay,
|
||||
registerTitleItem,
|
||||
registerToolWindow,
|
||||
} from "@/workbench/contributions";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { getContext } from "@/platform/context";
|
||||
import { lazyComponent } from "@/ui";
|
||||
import { registerVcsActions } from "./actions";
|
||||
import { installChangelists } from "./changelists";
|
||||
import { registerHistoryActions, trackOperationContext } from "./historyActions";
|
||||
import { controlLabel, controlOperation, inProgress } from "./operations";
|
||||
import { blameSlot } from "./blame";
|
||||
import { annotationsShown, blameSlot } from "./blame";
|
||||
import { BranchWidget, useBranchesPopup } from "./BranchWidget";
|
||||
import { showConflictsDialog } from "./conflictsUi";
|
||||
import { registerCompareActions } from "./compare";
|
||||
@@ -103,7 +105,10 @@ export function activate(): () => void {
|
||||
installIncomingCheck(),
|
||||
installFileConfirmations(),
|
||||
// Settings › Git › Sign-off commit: the default of Commit Options › Sign-off Commit.
|
||||
onWorkflowSettingsChange((w) => w.vcs.git.signOff, (signOff) => useCommit.setState({ signOff })),
|
||||
onWorkflowSettingsChange(
|
||||
(w) => w.vcs.git.signOff,
|
||||
(signOff) => useCommit.setState({ signOff }),
|
||||
),
|
||||
registerVcsActions(),
|
||||
registerHistoryActions(),
|
||||
registerLocalHistoryActions(),
|
||||
@@ -159,6 +164,21 @@ export function activate(): () => void {
|
||||
order: 60,
|
||||
extensions: (ctx) => [changeMarkers(ctx), blameSlot()],
|
||||
}),
|
||||
registerMenuGroup({
|
||||
id: "vcs.gutter",
|
||||
menus: ["editorGutter"],
|
||||
order: 10,
|
||||
items: (_menu, { paths: [path] }) => {
|
||||
if (!path || !getContext().vcsAvailable) return [];
|
||||
const shown = editorsFor(path).some((h) => annotationsShown(h.view));
|
||||
return [
|
||||
{
|
||||
label: shown ? "Close Annotations" : "Annotate with Git Blame",
|
||||
run: () => void executeAction("vcs.annotate", path),
|
||||
},
|
||||
];
|
||||
},
|
||||
}),
|
||||
];
|
||||
return () => {
|
||||
onConflictsAppeared(() => undefined);
|
||||
|
||||
@@ -510,9 +510,9 @@ export function projectViewRoots(map: ReadonlyMap<string, ProjectViewRootContrib
|
||||
// ---------------------------------------------------------------------------
|
||||
// Context menu groups: features add items to the editor, project view and
|
||||
// editor tab context menus (IDEA's EditorPopupMenu / ProjectViewPopupMenu /
|
||||
// EditorTabPopupMenu groups), e.g. "Run 'hi.ts'" from features/run.
|
||||
// EditorTabPopupMenu / EditorGutterPopupMenu groups), e.g. "Run 'hi.ts'" from features/run.
|
||||
|
||||
export type ContextMenuId = "editor" | "projectView" | "editorTab";
|
||||
export type ContextMenuId = "editor" | "projectView" | "editorTab" | "editorGutter";
|
||||
|
||||
export interface MenuGroupContext {
|
||||
/** Files / directories the menu is for (absolute paths; a virtual URI for virtual documents). */
|
||||
@@ -521,7 +521,7 @@ export interface MenuGroupContext {
|
||||
dirs?: boolean[];
|
||||
/** The document text, when the menu is for an open document. */
|
||||
text?: string;
|
||||
/** Editor menu: 0-based caret line. */
|
||||
/** Editor menu: 0-based caret line; gutter menu: the clicked line. */
|
||||
line?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -371,6 +371,20 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.stripeDragged {
|
||||
opacity: 0.4;
|
||||
}
|
||||
.stripeGhost {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
margin: 0;
|
||||
pointer-events: none;
|
||||
background: var(--bg-popup);
|
||||
border-radius: var(--radius-toolbar-button);
|
||||
box-shadow: var(--shadow-popup);
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* Settings › Appearance › "Different tool window background". */
|
||||
:global(:root[data-tool-window-bg="different"]) .anchor {
|
||||
background: var(--bg-elev);
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type DragEvent,
|
||||
type CSSProperties,
|
||||
type KeyboardEvent,
|
||||
type PointerEvent,
|
||||
@@ -251,8 +250,92 @@ function StripeHandle({
|
||||
);
|
||||
}
|
||||
|
||||
/** MIME type of a dragged stripe button (the tool window id). */
|
||||
export const TOOL_WINDOW_MIME = "application/x-openidea-toolwindow";
|
||||
// Stripe button drag. Pointer events rather than HTML5 drag and drop: with the window's native
|
||||
// file drop enabled, the webview never sees dragover / drop for drags that start inside it.
|
||||
|
||||
type StripeDrop = { group: StripeGroup; before: string | null };
|
||||
|
||||
const useStripeDrag = create<{ id: string | null; drop: StripeDrop | null }>(() => ({ id: null, drop: null }));
|
||||
|
||||
/** Movement before a press on a stripe button becomes a drag, px. */
|
||||
const DRAG_THRESHOLD = 4;
|
||||
/** Set when a drag ends on its own button, so the click that follows doesn't toggle the window. */
|
||||
let dragEnded = false;
|
||||
|
||||
/** Drop position under the pointer: a stripe group and the button to insert before (null: at the end). */
|
||||
function stripeDropAt(x: number, y: number): StripeDrop | null {
|
||||
const nav = document.elementFromPoint(x, y)?.closest<HTMLElement>("[data-stripe-side]");
|
||||
const side = nav?.dataset.stripeSide;
|
||||
if (!nav || (side !== "left" && side !== "right")) return null;
|
||||
const spacer = nav.querySelector<HTMLElement>("[data-stripe-spacer]")?.getBoundingClientRect();
|
||||
const lower = !!spacer && y > spacer.top + spacer.height / 2;
|
||||
let before: string | null = null;
|
||||
for (const b of nav.querySelectorAll<HTMLElement>("[data-stripe-button]")) {
|
||||
const r = b.getBoundingClientRect();
|
||||
if (spacer && r.top > spacer.top !== lower) continue;
|
||||
if (y < r.top + r.height / 2) {
|
||||
before = b.dataset.stripeButton!;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { group: `${side}-${lower ? "bottom" : "top"}`, before };
|
||||
}
|
||||
|
||||
function startStripeDrag(e: PointerEvent<HTMLButtonElement>, id: string) {
|
||||
if (e.button !== 0) return;
|
||||
const button = e.currentTarget;
|
||||
const start = { x: e.clientX, y: e.clientY };
|
||||
let ghost: HTMLElement | null = null;
|
||||
const place = (x: number, y: number) => {
|
||||
if (ghost) ghost.style.transform = `translate(${x - start.x}px, ${y - start.y}px)`;
|
||||
};
|
||||
const onMove = (ev: globalThis.PointerEvent) => {
|
||||
if (!ghost) {
|
||||
if (Math.hypot(ev.clientX - start.x, ev.clientY - start.y) < DRAG_THRESHOLD) return;
|
||||
const r = button.getBoundingClientRect();
|
||||
ghost = button.cloneNode(true) as HTMLElement;
|
||||
ghost.removeAttribute("data-stripe-button");
|
||||
ghost.className = clsx(button.className, styles.stripeGhost);
|
||||
Object.assign(ghost.style, {
|
||||
left: `${r.left}px`,
|
||||
top: `${r.top}px`,
|
||||
width: `${r.width}px`,
|
||||
height: `${r.height}px`,
|
||||
});
|
||||
document.body.appendChild(ghost);
|
||||
useStripeDrag.setState({ id, drop: null });
|
||||
}
|
||||
place(ev.clientX, ev.clientY);
|
||||
const drop = stripeDropAt(ev.clientX, ev.clientY);
|
||||
const cur = useStripeDrag.getState().drop;
|
||||
if (drop?.group !== cur?.group || drop?.before !== cur?.before) useStripeDrag.setState({ drop });
|
||||
};
|
||||
const finish = (commit: boolean) => {
|
||||
window.removeEventListener("pointermove", onMove);
|
||||
window.removeEventListener("pointerup", onUp);
|
||||
window.removeEventListener("pointercancel", onCancel);
|
||||
window.removeEventListener("keydown", onKey, true);
|
||||
if (!ghost) return;
|
||||
ghost.remove();
|
||||
const { drop } = useStripeDrag.getState();
|
||||
useStripeDrag.setState({ id: null, drop: null });
|
||||
dragEnded = true;
|
||||
setTimeout(() => (dragEnded = false));
|
||||
if (commit && drop && drop.before !== id) moveToolWindow(id, drop.group, drop.before);
|
||||
};
|
||||
const onUp = () => finish(true);
|
||||
const onCancel = () => finish(false);
|
||||
const onKey = (ev: globalThis.KeyboardEvent) => {
|
||||
if (ev.key !== "Escape" || !ghost) return;
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
finish(false);
|
||||
};
|
||||
window.addEventListener("pointermove", onMove);
|
||||
window.addEventListener("pointerup", onUp);
|
||||
window.addEventListener("pointercancel", onCancel);
|
||||
window.addEventListener("keydown", onKey, true);
|
||||
}
|
||||
|
||||
function StripeBadge({ useBadge }: { useBadge: () => number | string | null }) {
|
||||
const value = useBadge();
|
||||
@@ -274,6 +357,7 @@ function StripeButton({
|
||||
showName: boolean;
|
||||
}) {
|
||||
const shortcut = shortcutLabel(`toolwindow.${tw.id}`);
|
||||
const dragged = useStripeDrag((s) => s.id === tw.id);
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
@@ -283,17 +367,16 @@ function StripeButton({
|
||||
active && styles.stripeActive,
|
||||
active && focused && styles.stripeFocused,
|
||||
side === "right" && styles.stripeRight,
|
||||
dragged && styles.stripeDragged,
|
||||
)}
|
||||
aria-label={tx(tw.title)}
|
||||
aria-pressed={active}
|
||||
aria-keyshortcuts={shortcut}
|
||||
data-stripe-button={tw.id}
|
||||
draggable
|
||||
onDragStart={(e) => {
|
||||
e.dataTransfer.setData(TOOL_WINDOW_MIME, tw.id);
|
||||
e.dataTransfer.effectAllowed = "move";
|
||||
onPointerDown={(e) => startStripeDrag(e, tw.id)}
|
||||
onClick={() => {
|
||||
if (!dragEnded) toggleToolWindow(tw.id);
|
||||
}}
|
||||
onClick={() => toggleToolWindow(tw.id)}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
showContextMenu(e, stripeButtonMenu(tw, showName));
|
||||
@@ -388,26 +471,7 @@ export function ToolWindowStripe({
|
||||
const bottom = onStripe.filter((w) => stripeGroupOf(w) === `${side}-bottom`);
|
||||
const moreWindows = windows.filter((w) => !onStripe.includes(w));
|
||||
const focused = useToolWindowLayout((s) => s.focused);
|
||||
const navRef = useRef<HTMLElement>(null);
|
||||
const [drop, setDrop] = useState<{ group: StripeGroup; before: string | null } | null>(null);
|
||||
|
||||
const target = (e: DragEvent): { group: StripeGroup; before: string | null } => {
|
||||
const spacer = navRef.current?.querySelector<HTMLElement>("[data-stripe-spacer]");
|
||||
const spacerRect = spacer?.getBoundingClientRect();
|
||||
const lower = !!spacerRect && e.clientY > spacerRect.top + spacerRect.height / 2;
|
||||
const group: StripeGroup = `${side}-${lower ? "bottom" : "top"}`;
|
||||
const list = lower ? bottom : top;
|
||||
let before: string | null = null;
|
||||
for (const w of list) {
|
||||
const r = navRef.current?.querySelector<HTMLElement>(`[data-stripe-button="${w.id}"]`)?.getBoundingClientRect();
|
||||
if (r && e.clientY < r.top + r.height / 2) {
|
||||
before = w.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { group, before };
|
||||
};
|
||||
const isDrag = (e: DragEvent) => [...e.dataTransfer.types].includes(TOOL_WINDOW_MIME);
|
||||
const drop = useStripeDrag((s) => s.drop);
|
||||
|
||||
const indicator = (group: StripeGroup, before: string | null) =>
|
||||
drop && drop.group === group && drop.before === before ? (
|
||||
@@ -427,7 +491,6 @@ export function ToolWindowStripe({
|
||||
|
||||
return (
|
||||
<nav
|
||||
ref={navRef}
|
||||
aria-label={side === "left" ? "Tool windows" : "Right tool windows"}
|
||||
role="toolbar"
|
||||
aria-orientation="vertical"
|
||||
@@ -439,24 +502,6 @@ export function ToolWindowStripe({
|
||||
side === "right" ? styles.stripeSideRight : styles.stripeSideLeft,
|
||||
)}
|
||||
onKeyDown={onStripeKeyDown}
|
||||
onDragOver={(e) => {
|
||||
if (!isDrag(e)) return;
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = "move";
|
||||
const t = target(e);
|
||||
if (!drop || drop.group !== t.group || drop.before !== t.before) setDrop(t);
|
||||
}}
|
||||
onDragLeave={(e) => {
|
||||
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setDrop(null);
|
||||
}}
|
||||
onDrop={(e) => {
|
||||
if (!isDrag(e)) return;
|
||||
e.preventDefault();
|
||||
const id = e.dataTransfer.getData(TOOL_WINDOW_MIME);
|
||||
const t = target(e);
|
||||
setDrop(null);
|
||||
if (id && id !== t.before) moveToolWindow(id, t.group, t.before);
|
||||
}}
|
||||
>
|
||||
{renderGroup(`${side}-top`, top)}
|
||||
{side === "left" && <StripeMore windows={moreWindows} />}
|
||||
@@ -788,7 +833,9 @@ export function ToolWindowLayout({ editor }: { editor: ReactNode }) {
|
||||
const hasRight = windows.some(
|
||||
(w) => w.anchor === "right" && (hasStripeButton(w, stripeButtons) || visible.right === w.id),
|
||||
);
|
||||
const rightStripe = bars && hasRight;
|
||||
// While a stripe button is dragged, an empty right stripe shows as a drop target.
|
||||
const dragging = useStripeDrag((s) => !!s.id);
|
||||
const rightStripe = bars && (hasRight || dragging);
|
||||
const gridRef = useRef<HTMLDivElement>(null);
|
||||
const editorRef = useRef<HTMLDivElement>(null);
|
||||
const sync = () => {
|
||||
|
||||
Reference in new issue
Заблокувати користувача