Skip to content

Commit 4ee69c7

Browse files
committed
fix: clean up whitespace and formatting in linkAware functions
fix rediff
1 parent cd87fbd commit 4ee69c7

File tree

4 files changed

+27
-45
lines changed

4 files changed

+27
-45
lines changed

packages/bruno-app/src/components/CodeEditor/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class CodeEditor extends React.Component {
4848
componentDidMount() {
4949
const variables = getAllVariables(this.props.collection, this.props.item);
5050

51-
const editor = CodeMirror(this._node, {
51+
const editor = (this.editor = CodeMirror(this._node, {
5252
value: this.props.value || '',
5353
lineNumbers: true,
5454
lineWrapping: this.props.enableLineWrapping ?? true,
@@ -144,7 +144,7 @@ export default class CodeEditor extends React.Component {
144144
} else var toParse = '{' + internal + '}';
145145
try {
146146
count = Object.keys(JSON.parse(toParse)).length;
147-
} catch (e) { }
147+
} catch (e) {}
148148
} else if (this.props.mode == 'application/xml') {
149149
var doc = new DOMParser();
150150
try {
@@ -154,12 +154,12 @@ export default class CodeEditor extends React.Component {
154154
'application/xml'
155155
);
156156
count = dcm.documentElement.children.length;
157-
} catch (e) { }
157+
} catch (e) {}
158158
}
159159
return count ? `\u21A4${count}\u21A6` : '\u2194';
160160
}
161161
}
162-
});
162+
}));
163163
CodeMirror.registerHelper('lint', 'json', function (text) {
164164
let found = [];
165165
if (!window.jsonlint) {
@@ -185,7 +185,7 @@ export default class CodeEditor extends React.Component {
185185
}
186186
return found;
187187
});
188-
188+
189189
if (editor) {
190190
editor.setOption('lint', this.props.mode && editor.getValue().trim().length > 0 ? this.lintOptions : false);
191191
editor.on('change', this._onEdit);
@@ -194,7 +194,7 @@ export default class CodeEditor extends React.Component {
194194
this.addOverlay();
195195

196196
const getAllVariablesHandler = () => getAllVariables(this.props.collection, this.props.item);
197-
197+
198198
// Setup AutoComplete Helper for all modes
199199
const autoCompleteOptions = {
200200
showHintsFor: this.props.showHintsFor,

packages/bruno-app/src/components/RequestPane/QueryEditor/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class QueryEditor extends React.Component {
3636
}
3737

3838
componentDidMount() {
39-
const editor = CodeMirror(this._node, {
39+
const editor = (this.editor = CodeMirror(this._node, {
4040
value: this.props.value || '',
4141
lineNumbers: true,
4242
tabSize: 2,
@@ -131,7 +131,7 @@ export default class QueryEditor extends React.Component {
131131
'Cmd-F': 'findPersistent',
132132
'Ctrl-F': 'findPersistent'
133133
}
134-
});
134+
}));
135135
if (editor) {
136136
editor.on('change', this._onEdit);
137137
editor.on('keyup', this._onKeyUp);

packages/bruno-app/src/utils/codemirror/linkAware.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function markUrls(editor, linkify, linkClass, linkHint) {
2626
className: linkClass,
2727
attributes: {
2828
'data-url': url,
29-
title: linkHint
29+
'title': linkHint
3030
}
3131
});
3232
});
@@ -42,18 +42,18 @@ function markUrls(editor, linkify, linkClass, linkHint) {
4242
function handleMouseEnter(event, linkClass, linkHoverClass, updateCmdCtrlClass) {
4343
const el = event.target;
4444
if (!el.classList.contains(linkClass)) return;
45-
45+
4646
updateCmdCtrlClass(event);
4747

4848
el.classList.add(linkHoverClass);
49-
49+
5050
// Add hover effect to previous siblings that are also links
5151
let sibling = el.previousElementSibling;
5252
while (sibling && sibling.classList.contains(linkClass)) {
5353
sibling.classList.add(linkHoverClass);
5454
sibling = sibling.previousElementSibling;
5555
}
56-
56+
5757
// Add hover effect to next siblings that are also links
5858
sibling = el.nextElementSibling;
5959
while (sibling && sibling.classList.contains(linkClass)) {
@@ -71,14 +71,14 @@ function handleMouseEnter(event, linkClass, linkHoverClass, updateCmdCtrlClass)
7171
function handleMouseLeave(event, linkClass, linkHoverClass) {
7272
const el = event.target;
7373
el.classList.remove(linkHoverClass);
74-
74+
7575
// Remove hover effect from previous siblings that are also links
7676
let sibling = el.previousElementSibling;
7777
while (sibling && sibling.classList.contains(linkClass)) {
7878
sibling.classList.remove(linkHoverClass);
7979
sibling = sibling.previousElementSibling;
8080
}
81-
81+
8282
// Remove hover effect from next siblings that are also links
8383
sibling = el.nextElementSibling;
8484
while (sibling && sibling.classList.contains(linkClass)) {

packages/bruno-app/src/utils/codemirror/linkAware.spec.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -143,31 +143,27 @@ describe('setupLinkAware', () => {
143143
setupLinkAware(mockEditor);
144144

145145
// Verify that markUrls was called which sets the hint
146-
expect(mockEditor.markText).toHaveBeenCalledWith(
147-
expect.anything(),
146+
expect(mockEditor.markText).toHaveBeenCalledWith(expect.anything(),
148147
expect.anything(),
149148
expect.objectContaining({
150149
attributes: expect.objectContaining({
151150
title: 'Hold Cmd and click to open link'
152151
})
153-
})
154-
);
152+
}));
155153
});
156154

157155
it('should use Ctrl key hint on non-macOS', () => {
158156
isMacOS.mockReturnValue(false);
159157
setupLinkAware(mockEditor);
160158

161159
// Verify that markUrls was called which sets the hint
162-
expect(mockEditor.markText).toHaveBeenCalledWith(
163-
expect.anything(),
160+
expect(mockEditor.markText).toHaveBeenCalledWith(expect.anything(),
164161
expect.anything(),
165162
expect.objectContaining({
166163
attributes: expect.objectContaining({
167164
title: 'Hold Ctrl and click to open link'
168165
})
169-
})
170-
);
166+
}));
171167
});
172168
});
173169

@@ -306,17 +302,15 @@ describe('setupLinkAware', () => {
306302
it('should apply link tooltips when marking URLs', () => {
307303
setupLinkAware(mockEditor);
308304

309-
expect(mockEditor.markText).toHaveBeenCalledWith(
310-
{ line: 0, ch: 10 },
305+
expect(mockEditor.markText).toHaveBeenCalledWith({ line: 0, ch: 10 },
311306
{ line: 0, ch: 28 },
312307
{
313308
className: 'CodeMirror-link',
314309
attributes: {
315310
'data-url': 'https://example.com',
316-
title: 'Hold Cmd and click to open link'
311+
'title': 'Hold Cmd and click to open link'
317312
}
318-
}
319-
);
313+
});
320314
});
321315
});
322316

@@ -338,9 +332,7 @@ describe('setupLinkAware', () => {
338332
it('should add hover class on mouseover for link elements', () => {
339333
setupLinkAware(mockEditor);
340334

341-
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find(
342-
(call) => call[0] === 'mouseover'
343-
)[1];
335+
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find((call) => call[0] === 'mouseover')[1];
344336

345337
const mockTarget = {
346338
classList: {
@@ -377,9 +369,7 @@ describe('setupLinkAware', () => {
377369
it('should not add hover class for non-link elements', () => {
378370
setupLinkAware(mockEditor);
379371

380-
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find(
381-
(call) => call[0] === 'mouseover'
382-
)[1];
372+
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find((call) => call[0] === 'mouseover')[1];
383373

384374
const mockTarget = {
385375
classList: {
@@ -431,9 +421,7 @@ describe('setupLinkAware', () => {
431421
it('should handle multi-span links correctly on hover', () => {
432422
setupLinkAware(mockEditor);
433423

434-
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find(
435-
(call) => call[0] === 'mouseover'
436-
)[1];
424+
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find((call) => call[0] === 'mouseover')[1];
437425

438426
// Create a mock with a chain of link spans
439427
const mockNestedPrev = {
@@ -508,9 +496,7 @@ describe('setupLinkAware', () => {
508496
it('should handle missing target in mouse event', () => {
509497
setupLinkAware(mockEditor);
510498

511-
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find(
512-
(call) => call[0] === 'mouseover'
513-
)[1];
499+
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find((call) => call[0] === 'mouseover')[1];
514500
const mockEvent = { target: null };
515501

516502
// Note: This will throw as the implementation accesses target.classList without null check
@@ -546,9 +532,7 @@ describe('setupLinkAware', () => {
546532
it('should handle null siblings in mouseover events', () => {
547533
setupLinkAware(mockEditor);
548534

549-
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find(
550-
(call) => call[0] === 'mouseover'
551-
)[1];
535+
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find((call) => call[0] === 'mouseover')[1];
552536

553537
const mockTarget = {
554538
classList: {
@@ -568,9 +552,7 @@ describe('setupLinkAware', () => {
568552
it('should handle non-link siblings in mouseover events', () => {
569553
setupLinkAware(mockEditor);
570554

571-
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find(
572-
(call) => call[0] === 'mouseover'
573-
)[1];
555+
const mouseoverHandler = mockWrapperElement.addEventListener.mock.calls.find((call) => call[0] === 'mouseover')[1];
574556

575557
const mockPrev = {
576558
classList: {

0 commit comments

Comments
 (0)