Skip to content

Commit bde8f9f

Browse files
committed
feat: polish references peek UX and release build config
1 parent c251da5 commit bde8f9f

11 files changed

Lines changed: 240 additions & 96 deletions

File tree

anycode-backend/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

anycode-backend/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[package]
22
name = "anycode"
3-
version = "0.0.8"
3+
version = "0.0.13"
44
edition = "2024"
55

66
[profile.release]
77
# opt-level = 3
88
# strip = true
9-
# lto = true
9+
lto = true
10+
codegen-units = 1
1011
panic = 'abort'
1112

1213
[dependencies]

anycode-base/src/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export enum Action {
3030
DUPLICATE = 'DUPLICATE',
3131
COMMENT = 'COMMENT',
3232
GO_TO_DEFINITION = 'GO_TO_DEFINITION',
33+
REFERENCES = 'OPEN_REFERENCES_PEEK',
3334
HOVER = 'HOVER',
3435
}
3536

anycode-base/src/editor.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,13 @@ export class AnycodeEditor {
901901
return;
902902
}
903903

904+
if (action === Action.REFERENCES) {
905+
event.preventDefault();
906+
const { line, column } = this.code.getPosition(this.offset);
907+
this.openReferencesPeek(line, column).catch(console.error);
908+
return;
909+
}
910+
904911
if (action === Action.HOVER) {
905912
event.preventDefault();
906913
if (!this.hoverProvider) return;
@@ -984,6 +991,7 @@ export class AnycodeEditor {
984991
case "Tab": return Action.TAB;
985992
case "Escape": return Action.ESC;
986993
case "F10": return Action.HOVER;
994+
case "F11": return Action.REFERENCES;
987995
case "F12": return Action.GO_TO_DEFINITION;
988996
}
989997

anycode/App.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ const App: React.FC = () => {
172172
return;
173173
}
174174

175-
if (e.shiftKey && e.key === 'F12') {
176-
e.preventDefault();
177-
editors.openReferencesPeekForActiveCursor();
178-
return;
179-
}
180-
181175
if (e.metaKey && e.key === 'f') {
182176
e.preventDefault();
183177
}
@@ -206,7 +200,6 @@ const App: React.FC = () => {
206200
editors.activeEditorPaneId,
207201
editors.activeFileId,
208202
editors.handleReferencesPeekKeyDown,
209-
editors.openReferencesPeekForActiveCursor,
210203
editors.redoCursor,
211204
editors.saveFile,
212205
editors.undoCursor,

anycode/features/editor/EditorPanel.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type EditorPanelProps = {
1111
setActiveEditorPaneId: (paneId: string) => void;
1212
getReferencesPeekForPane: (paneId: string) => ReferencesPeekState | null;
1313
closeReferencesPeek: (paneId?: string) => void;
14+
focusEditorInPane: (paneId: string) => void;
1415
setSelectedReferenceInPeek: (paneId: string, nextIndex: number) => void;
1516
openReferenceFromPeek: (paneId: string, itemIndex?: number) => void;
1617
};
@@ -39,7 +40,10 @@ export const EditorPanel = ({ panelKey, editors }: EditorPanelProps) => {
3940
{referencesPeek ? (
4041
<ReferencesPeek
4142
state={referencesPeek}
42-
onClose={() => editors.closeReferencesPeek(panelKey)}
43+
onClose={() => {
44+
editors.closeReferencesPeek(panelKey);
45+
editors.focusEditorInPane(panelKey);
46+
}}
4347
onSelectItem={(index) => editors.setSelectedReferenceInPeek(panelKey, index)}
4448
onOpenItem={(index) => editors.openReferenceFromPeek(panelKey, index)}
4549
/>

anycode/features/editor/ReferencesPeek.css

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
.references-peek-preview-editor .anyeditor .buttons,
107107
.references-peek-preview-editor .anyeditor .gutter {
108108
opacity: 0.72;
109+
position: relative;
110+
left: auto;
109111
}
110112

111113
.references-peek-preview-editor .anyeditor.readonly .buttons {
@@ -144,35 +146,81 @@
144146
color: #aaa;
145147
}
146148

149+
.references-peek-group-path {
150+
min-width: 0;
151+
overflow: hidden;
152+
text-overflow: ellipsis;
153+
white-space: nowrap;
154+
}
155+
147156
.references-peek-item {
148157
width: 100%;
149-
text-align: left;
150-
border: 1px solid transparent;
151-
border-radius: 9px;
152158
background: transparent;
153159
color: #fff;
154-
padding: 7px 9px;
160+
padding: 0;
155161
margin-top: 4px;
156-
display: flex;
157-
align-items: center;
162+
position: relative;
158163
outline: none;
159164
}
160165

161-
.references-peek-item:hover {
166+
.references-peek-item-select {
167+
width: 100%;
168+
min-width: 0;
169+
text-align: left;
170+
border: none;
162171
background: transparent;
172+
color: inherit;
173+
padding: 7px 72px 7px 9px;
174+
border-radius: 9px;
175+
margin: 0;
176+
outline: none;
163177
}
164178

165-
.references-peek-item:focus,
166-
.references-peek-item:focus-visible,
167-
.references-peek-item:active {
179+
.references-peek-item-select:focus,
180+
.references-peek-item-select:focus-visible,
181+
.references-peek-item-select:active {
168182
outline: none;
169183
box-shadow: none;
170-
border-color: transparent;
171184
}
172185

173186
.references-peek-item.is-selected {
187+
background: transparent;
188+
}
189+
190+
.references-peek-item-select.is-selected {
174191
background: rgba(130, 130, 130, 0.33);
175-
border-color: transparent;
192+
}
193+
194+
.references-peek-item-open {
195+
position: absolute;
196+
right: 8px;
197+
top: 50%;
198+
transform: translateY(-50%) translateX(2px);
199+
border: 1px solid rgba(255, 255, 255, 0.16);
200+
border-radius: 7px;
201+
padding: 4px 8px;
202+
font-size: 11px;
203+
color: #ddd;
204+
background: rgba(255, 255, 255, 0.06);
205+
flex-shrink: 0;
206+
min-width: 52px;
207+
opacity: 0;
208+
visibility: hidden;
209+
pointer-events: none;
210+
transition: opacity 0.12s ease, visibility 0.12s ease, transform 0.12s ease, background-color 0.12s ease, color 0.12s ease;
211+
}
212+
213+
.references-peek-item:hover .references-peek-item-open,
214+
.references-peek-item:focus-within .references-peek-item-open {
215+
opacity: 1;
216+
visibility: visible;
217+
pointer-events: auto;
218+
transform: translateY(-50%) translateX(0);
219+
}
220+
221+
.references-peek-item-open:hover {
222+
background: rgba(255, 255, 255, 0.11);
223+
color: #fff;
176224
}
177225

178226
.references-peek-item-location {

0 commit comments

Comments
 (0)