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) {
this.triggerEvent('didChangeFile', [file])
const currentFile = await this.call('fileManager', 'file')
if (!currentFile) {
return

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

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

@ -1,11 +1,34 @@
// eslint-disable-next-line no-use-before-define
import React from 'react'
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
import { fileDecoration } from '../../types'
const FileDecorationErrorIcon = (props: {
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

@ -1,21 +1,10 @@
export enum fileDecorationType {
Error = 'ERROR',
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',
None = 'NONE'
}
export type fileDecoration = {
path: string,
isDirectory: boolean,
@ -28,6 +17,7 @@ export enum fileDecorationType {
owner: string,
workspace?: any
tooltip?: string
commment?: string[] | string
}
export interface FileType {

Loading…
Cancel
Save