Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update tab set value #750

Merged
merged 3 commits into from
May 26, 2022
Merged

fix: update tab set value #750

merged 3 commits into from
May 26, 2022

Conversation

Zaoei
Copy link
Collaborator

@Zaoei Zaoei commented May 24, 2022

Description

Can't update editor's value via the updateTab method

Fixes #714

Changes

  • editorInstance.onDidChangeModelContent added comparisons are made through URIs to limit changes to different editors。This is because when you change the contents of the editor with setValue, the onDidChangeModelContent event is triggered, and leaving it unchecked will cause the updateTab method to be called in onDidChangeModelContent, causing a circular call
  • In the updateTab method, check if tab.data.value exists, and call setGroupEditorValue to update the editor text

How Has This Been Tested?

  • use updateTab method
const handleSubmit = () => {
    molecule.editor.updateTab({
        id: current.tab.id,
       // update the editor's value by str
       data: Object.assign(current.tab.data,{value: str})
    })
}
  • View changes in editor text content

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #750 (25717bd) into main (05ad264) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #750      +/-   ##
==========================================
+ Coverage   91.34%   91.40%   +0.06%     
==========================================
  Files         189      189              
  Lines        5947     5966      +19     
  Branches     1426     1435       +9     
==========================================
+ Hits         5432     5453      +21     
+ Misses        508      506       -2     
  Partials        7        7              
Impacted Files Coverage Δ
src/controller/editor.tsx 48.34% <100.00%> (+1.04%) ⬆️
src/services/workbench/editorService.ts 96.86% <100.00%> (+0.12%) ⬆️
src/components/tabs/tab.tsx 100.00% <0.00%> (ø)
src/components/tabs/tabExtra.tsx 100.00% <0.00%> (ø)
src/workbench/sidebar/explore/folderTree.tsx 100.00% <0.00%> (ø)
src/components/tree/index.tsx 98.99% <0.00%> (+0.01%) ⬆️
src/components/breadcrumb/index.tsx 93.33% <0.00%> (+0.47%) ⬆️
src/workbench/editor/action.tsx 89.74% <0.00%> (+5.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05ad264...25717bd. Read the comment docs.

@Zaoei Zaoei requested review from mortalYoung, mumiao and wewoor May 24, 2022 09:26
@Zaoei Zaoei changed the title Fix/update tab set value Fix: update tab set value May 24, 2022
@Zaoei Zaoei changed the title Fix: update tab set value fix: update tab set value May 24, 2022
return updatedTab;
}

public setGroupEditorValue(group: IEditorGroup, value: string) {
const modal = group.editorInstance?.getModel();
if (!modal) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!modal) return;
if (!model) return;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@Zaoei Zaoei force-pushed the fix/updateTabSetValue branch from 1299ff1 to 25717bd Compare May 25, 2022 10:12
@mumiao mumiao added the bug Something isn't working label May 25, 2022
@mumiao mumiao added this to the 0.9.0-beta.5 milestone May 25, 2022
@mumiao
Copy link
Collaborator

mumiao commented May 25, 2022

+1

@mumiao mumiao merged commit f97e00c into DTStack:main May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Can't update editor's value via the updateTab method
2 participants