speed improvements & tooltips

pull/5370/head
filip mertens 2 years ago
parent 59fa60fb2f
commit 6b35ac31b1
  1. 1
      apps/remix-ide/src/app/editor/editor.js
  2. 7
      apps/remix-ide/src/app/plugins/code-parser.tsx
  3. 14
      libs/remix-ui/editor/src/lib/actions/editor.ts
  4. 25
      libs/remix-ui/file-decorators/src/lib/components/filedecorationicons/file-decoration-error-icon.tsx
  5. 14
      libs/remix-ui/file-decorators/src/lib/types/index.ts

@ -211,6 +211,7 @@ class Editor extends Plugin {
} }
async _onChange (file) { async _onChange (file) {
this.triggerEvent('didChangeFile', [file])
const currentFile = await this.call('fileManager', 'file') const currentFile = await this.call('fileManager', 'file')
if (!currentFile) { if (!currentFile) {
return return

@ -51,8 +51,8 @@ export class CodeParser extends Plugin {
} }
async onActivation() { async onActivation() {
this.on('editor', 'contentChanged', async () => { this.on('editor', 'didChangeFile', async (file) => {
console.log('contentChanged') console.log('contentChanged', file)
await this.getCurrentFileAST() await this.getCurrentFileAST()
await this.compile() await this.compile()
}) })
@ -156,7 +156,8 @@ export class CodeParser extends Plugin {
fileStateIcon: '', fileStateIcon: '',
text: errors.length, text: errors.length,
owner: 'code-parser', owner: 'code-parser',
bubble: true bubble: true,
commment: errors.map((error) => error.message),
} }
decorators.push(decorator) decorators.push(decorator)
} }

@ -22,9 +22,9 @@ export const reducerActions = (models = initialState, action: Action) => {
if (models[uri]) return models // already existing if (models[uri]) return models // already existing
models[uri] = { language, uri, readOnly } models[uri] = { language, uri, readOnly }
let model let model
try{ try {
model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri)) model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri))
}catch(e){ } catch (e) {
} }
models[uri].model = model models[uri].model = model
@ -60,20 +60,20 @@ export const reducerActions = (models = initialState, action: Action) => {
case 'REVEAL_RANGE': { case 'REVEAL_RANGE': {
if (!editor) return models if (!editor) return models
const range: IRange = { const range: IRange = {
startLineNumber: action.payload.startLineNumber +1, startLineNumber: action.payload.startLineNumber + 1,
startColumn: action.payload.startColumn, startColumn: action.payload.startColumn,
endLineNumber: action.payload.endLineNumber + 1, endLineNumber: action.payload.endLineNumber + 1,
endColumn: action.payload.endColumn endColumn: action.payload.endColumn
} }
// reset to start of line // reset to start of line
if(action.payload.startColumn < 100){ if (action.payload.startColumn < 100) {
editor.revealRange({ editor.revealRange({
startLineNumber: range.startLineNumber, startLineNumber: range.startLineNumber,
startColumn: 1, startColumn: 1,
endLineNumber: range.endLineNumber, endLineNumber: range.endLineNumber,
endColumn: 1 endColumn: 1
}) })
}else{ } else {
editor.revealRangeInCenter(range) editor.revealRangeInCenter(range)
} }
return models return models
@ -138,12 +138,12 @@ export const reducerListener = (plugin, dispatch, monaco, editor, events) => {
plugin.on('editor', 'revealRange', (startLineNumber, startColumn, endLineNumber, endColumn) => { plugin.on('editor', 'revealRange', (startLineNumber, startColumn, endLineNumber, endColumn) => {
dispatch({ dispatch({
type: 'REVEAL_RANGE', type: 'REVEAL_RANGE',
payload: { payload: {
startLineNumber, startLineNumber,
startColumn, startColumn,
endLineNumber, endLineNumber,
endColumn endColumn
}, },
monaco, monaco,
editor editor
}) })

@ -1,11 +1,34 @@
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
import React from 'react' import React from 'react'
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
import { fileDecoration } from '../../types' import { fileDecoration } from '../../types'
const FileDecorationErrorIcon = (props: { const FileDecorationErrorIcon = (props: {
fileState: fileDecoration fileState: fileDecoration
}) => { }) => {
return <><span className={`${props.fileState.fileStateIconClass} text-danger pr-2`}>{props.fileState.text}</span></>
const getComments = function () {
if(props.fileState.commment){
const commments = Array.isArray(props.fileState.commment) ? props.fileState.commment : [props.fileState.commment]
return commments.map((comment, index) => {
return <div key={index}>{comment}<br></br></div>
})
}
}
return <>
<OverlayTrigger
placement='auto'
overlay={
<Tooltip id={`tooltip-${props.fileState.path}`}>
<>{getComments()}</>
</Tooltip>
}
>
<span className={`${props.fileState.fileStateIconClass} text-danger pr-2`}>{props.fileState.text}</span>
</OverlayTrigger>
</>
} }
export default FileDecorationErrorIcon export default FileDecorationErrorIcon

@ -1,21 +1,10 @@
export enum fileDecorationType { export enum fileDecorationType {
Error = 'ERROR', Error = 'ERROR',
Warning = 'WARNING', Warning = 'WARNING',
Success = 'SUCCESS',
Loading = 'LOADING',
Unsaved = 'UNSAVED',
Untracked = 'UNTRACKED',
Modified = 'MODIFIED',
Staged = 'STAGED',
Committed = 'COMMITTED',
Deleted = 'DELETED',
Added = 'ADDED',
New = 'NEW',
Compiled = 'COMPILED',
Custom = 'CUSTOM', Custom = 'CUSTOM',
None = 'NONE' None = 'NONE'
} }
export type fileDecoration = { export type fileDecoration = {
path: string, path: string,
isDirectory: boolean, isDirectory: boolean,
@ -28,6 +17,7 @@ export enum fileDecorationType {
owner: string, owner: string,
workspace?: any workspace?: any
tooltip?: string tooltip?: string
commment?: string[] | string
} }
export interface FileType { export interface FileType {

Loading…
Cancel
Save