Skip to content

Commit 82b545e

Browse files
authored
Merge branch 'master' into matomodesktop
2 parents 5c91251 + 8c9cbc0 commit 82b545e

File tree

9 files changed

+85
-116
lines changed

9 files changed

+85
-116
lines changed

apps/remix-ide-e2e/src/tests/code_format.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,17 @@ proposalNames.push(bytes32("candidate1"));
8080
}`
8181

8282
const formattedContract = `pragma solidity >=0.4.22 <0.9.0;
83-
8483
contract unfomattedContract {
8584
bytes32[] proposalNames;
86-
8785
function beforeAll() public {
8886
proposalNames.push(bytes32("candidate1"));
8987
ballotToTest = new Ballot(proposalNames);
9088
}
9189
}`
9290

9391
const formattedWithTabWidth2 = `pragma solidity >=0.4.22 <0.9.0;
94-
9592
contract unfomattedContract {
9693
bytes32[] proposalNames;
97-
9894
function beforeAll() public {
9995
proposalNames.push(bytes32("candidate1"));
10096
ballotToTest = new Ballot(proposalNames);

apps/remix-ide/src/app/panels/tab-proxy.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ export default class TabProxy extends Plugin {
186186
this.call('manager', 'deactivatePlugin', name)
187187
},
188188
icon,
189-
description
189+
description,
190+
show
190191
)
191192
show && this.switchTab(name)
192193
}
@@ -210,6 +211,10 @@ export default class TabProxy extends Plugin {
210211

211212
focus (name) {
212213
this.emit('switchApp', name)
214+
const tabIndex = this.loadedTabs.findIndex(tab => tab.name === name)
215+
if (tabIndex !== -1) {
216+
this.loadedTabs[tabIndex].show = true
217+
}
213218
this.tabsApi.activateTab(name)
214219
}
215220

@@ -259,7 +264,7 @@ export default class TabProxy extends Plugin {
259264
* @param {string} description
260265
* @returns
261266
*/
262-
addTab (name, title, switchTo, close, icon, description = '') {
267+
addTab (name, title, switchTo, close, icon, description = '', show = true) {
263268
if (this._handlers[name]) return this.renderComponent()
264269

265270
if ((name.endsWith('.vy') && icon === undefined) || title.includes('Vyper')) {
@@ -290,7 +295,8 @@ export default class TabProxy extends Plugin {
290295
title,
291296
icon,
292297
tooltip: name,
293-
iconClass: getPathIcon(name)
298+
iconClass: getPathIcon(name),
299+
show
294300
})
295301
formatPath.shift()
296302
if (formatPath.length > 0) {
@@ -307,7 +313,8 @@ export default class TabProxy extends Plugin {
307313
title: duplicateTabTitle,
308314
icon,
309315
tooltip: duplicateTabTooltip || duplicateTabTitle,
310-
iconClass: getPathIcon(duplicateTabName)
316+
iconClass: getPathIcon(duplicateTabName),
317+
show
311318
}
312319
}
313320
}
@@ -321,7 +328,8 @@ export default class TabProxy extends Plugin {
321328
title,
322329
icon,
323330
tooltip: description || title,
324-
iconClass: getPathIcon(name)
331+
iconClass: getPathIcon(name),
332+
show
325333
})
326334
}
327335

@@ -335,17 +343,29 @@ export default class TabProxy extends Plugin {
335343
if(!this.loadedTabs.find(tab => tab.name === name)) return // prevent removing tab that doesn't exist
336344
this.loadedTabs = this.loadedTabs.filter((tab, index) => {
337345
if (!previous && tab.name === name) {
338-
if(index - 1 >= 0 && this.loadedTabs[index - 1])
339-
previous = this.loadedTabs[index - 1]
340-
else if (index + 1 && this.loadedTabs[index + 1])
341-
previous = this.loadedTabs[index + 1]
346+
previous = this.getPreviousVisibleTab(index)
347+
if (!previous) previous = this.getNextVisibleTab(index)
342348
}
343349
return tab.name !== name
344350
})
345351
this.renderComponent()
346352
if (previous) this.switchTab(previous.name)
347353
}
348354

355+
getPreviousVisibleTab (index) {
356+
for (let i = index - 1; i >= 0; i--) {
357+
if (this.loadedTabs[i].show) return this.loadedTabs[i]
358+
}
359+
return null
360+
}
361+
362+
getNextVisibleTab (index) {
363+
for (let i = index + 1; i < this.loadedTabs.length; i++) {
364+
if (this.loadedTabs[i].show) return this.loadedTabs[i]
365+
}
366+
return null
367+
}
368+
349369
addHandler (type, fn) {
350370
this.handlers[type] = fn
351371
}

apps/remix-ide/src/app/plugins/code-format.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22
import { Plugin } from '@remixproject/engine'
3-
import { Options } from 'prettier';
4-
import sol from './code-format/index'
3+
import { Options } from 'prettier'
54
import path from 'path'
65
import yaml from 'js-yaml'
76
import toml from 'toml'
@@ -82,6 +81,7 @@ export class CodeFormat extends Plugin {
8281
this.babel = await import('prettier/parser-babel')
8382
this.espree = await import('prettier/parser-espree')
8483
this.yml = await import('prettier/parser-yaml')
84+
this.sol = (await import('prettier-plugin-solidity')).default
8585
}
8686

8787
try {
@@ -92,7 +92,7 @@ export class CodeFormat extends Plugin {
9292
}
9393
switch (path.extname(file)) {
9494
case '.sol':
95-
parserName = 'solidity-parse'
95+
parserName = 'slang'
9696
break
9797
case '.ts':
9898
parserName = 'typescript'
@@ -231,7 +231,7 @@ export class CodeFormat extends Plugin {
231231
}
232232
}
233233
})
234-
const validParsers = ['typescript', 'babel', 'espree', 'solidity-parse', 'json', 'yaml', 'solidity-parse']
234+
const validParsers = ['typescript', 'babel', 'espree', 'json', 'yaml', 'slang']
235235
if (override && override.options && override.options.parser) {
236236
if (validParsers.includes(override.options.parser)) {
237237
parserName = override.options.parser
@@ -249,8 +249,8 @@ export class CodeFormat extends Plugin {
249249
}
250250
}
251251

252-
const result = this.prettier.format(content, {
253-
plugins: [sol as any, this.ts, this.babel, this.espree, this.yml],
252+
const result = await this.prettier.format(content, {
253+
plugins: [this.sol, this.ts, this.babel, this.espree, this.yml],
254254
parser: parserName,
255255
...options
256256
})
@@ -260,6 +260,7 @@ export class CodeFormat extends Plugin {
260260
return result
261261
} catch (e) {
262262
// do nothing
263+
console.error(e)
263264
}
264265
}
265266

apps/remix-ide/src/app/plugins/code-format/index.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

apps/remix-ide/src/app/tabs/settings-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class SettingsTab extends ViewPlugin {
6666

6767
render() {
6868
return (
69-
<div id="settingsTab" className="bg-light">
69+
<div id="settingsTab" className="bg-light overflow-hidden">
7070
<PluginViewWrapper plugin={this} />
7171
</div>
7272
)

apps/remix-ide/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
137137
})
138138
)
139139

140+
config.plugins.push(
141+
new webpack.IgnorePlugin({ resourceRegExp: /^node:/ })
142+
)
143+
140144
// source-map loader
141145
config.module.rules.push({
142146
test: /\.js$/,

libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface Tab {
3434
name: string
3535
title: string
3636
tooltip: string
37+
show: boolean
3738
}
3839
export interface TabsUIApi {
3940
activateTab: (name: string) => void
@@ -95,7 +96,7 @@ export const TabsUI = (props: TabsUIProps) => {
9596
const [compileState, setCompileState] = useState<'idle' | 'compiling' | 'compiled'>('idle')
9697

9798
useEffect(() => {
98-
if (props.tabs[tabsState.selectedIndex]) {
99+
if (props.tabs[tabsState.selectedIndex] && props.tabs[tabsState.selectedIndex].show) {
99100
tabsRef.current[tabsState.selectedIndex].scrollIntoView({
100101
behavior: 'smooth',
101102
block: 'center'
@@ -614,14 +615,14 @@ export const TabsUI = (props: TabsUIProps) => {
614615
>
615616
<TabList className="d-flex flex-row align-items-center">
616617
{props.tabs.map((tab, i) => (
617-
<Tab className="" key={tab.name} data-id={tab.id}>
618+
<Tab className={tab.show ? '' : 'd-none'} key={tab.name} data-id={tab.id}>
618619
{renderTab(tab, i)}
619620
</Tab>
620621
))}
621622
<div style={{ minWidth: '4rem', height: '1rem' }} id="dummyElForLastXVisibility"></div>
622623
</TabList>
623624
{props.tabs.map((tab) => (
624-
<TabPanel key={tab.name}></TabPanel>
625+
<TabPanel className={tab.show ? '' : 'd-none'} key={tab.name}></TabPanel>
625626
))}
626627
</Tabs>
627628

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@
182182
"octokit": "^3.1.2",
183183
"path-browserify": "^1.0.1",
184184
"permissionless": "0.2.25",
185-
"prettier": "^2.8.4",
186-
"prettier-plugin-solidity": "^1.0.0-beta.24",
185+
"prettier": "^3.6.2",
186+
"prettier-plugin-solidity": "^2.1.0",
187187
"ra-data-graphql": "^4.16.11",
188188
"raw-loader": "^4.0.2",
189189
"react": "^18.2.0",
@@ -216,6 +216,7 @@
216216
"signale": "^1.4.0",
217217
"snarkjs": "^0.7.0",
218218
"sol2uml": "^2.4.3",
219+
"solidity-comments-extractor": "^0.0.8",
219220
"string-similarity": "^4.0.4",
220221
"svg2pdf.js": "^2.2.1",
221222
"text-encoding": "^0.7.0",

0 commit comments

Comments
 (0)