Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
84063e97
Commit
84063e97
authored
4 years ago
by
Loïc Correnson
Committed by
David Bühler
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[ivette/tables] fix operation API
parent
73806558
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/dome/src/renderer/text/buffers.js
+21
-10
21 additions, 10 deletions
ivette/src/dome/src/renderer/text/buffers.js
with
21 additions
and
10 deletions
ivette/src/dome/src/renderer/text/buffers.js
+
21
−
10
View file @
84063e97
...
...
@@ -443,16 +443,15 @@ is blocked.
/**
@summary Bind this buffer to a CodeMirror instance.
@param {CodeMirror} cm - code mirror instance to link this document in.
@return Document previous document of the instance
@description
Returns the CodeMirror document _previously_ linked to the `cm` instance.
Uses CodeMirror linked documents to allow several CodeMirror instances to be linked
to the same buffer.
*/
link
(
cm
)
{
const
newDoc
=
this
.
_doc
.
linkedDoc
(
{
sharedHist
:
true
}
);
const
oldDoc
=
cm
.
swapDoc
(
newDoc
);
cm
.
swapDoc
(
newDoc
);
this
.
_editors
.
push
(
cm
);
if
(
this
.
_operations
>
0
)
cm
.
startOperation
();
return
oldDoc
;
}
/**
...
...
@@ -469,6 +468,16 @@ is blocked.
if
(
this
.
_operations
>
0
)
cm
.
endOperation
();
}
/**
@summary Iterates over each linked CodeMirror instances
@description
The operation `fn` is performed on each code mirror
instance currently linked to this buffer.
*/
forEach
(
fn
)
{
this
.
_editors
.
forEach
(
fn
);
};
// --------------------------------------------------------------------------
// --- Stacked Operations
// --------------------------------------------------------------------------
...
...
@@ -478,21 +487,23 @@ is blocked.
@param {function} job - a function performing the operations (can return a promise)
@return {promise} the promised job
@description
Uses code mirror `cm.operation()` to batch the updating operations performed on the
buffer.
Uses code mirror `cm.startOperation()` and `cm.sendOperation()` on all
linked editors to batch the updating operations performed on the
buffer. The batched updates can run asynchronously.
*/
operation
(
job
)
{
// Invariant: this._operations is the number of batched job still running
// Invariant: when pending job are running, all linked this._editors are started
// Second invariant is also maintained by link and unlink methods
// Protect each start/end call against error
const
forEachEditor
=
(
fn
)
=>
{
this
.
_editors
.
forEach
((
cm
)
=>
{
try
{
fn
(
cm
);
}
catch
(
e
)
{
console
.
err
(
'
[Dome.text.buffers]
'
,
e
);
}
});
};
// Invariant: this._operations is the number of batched job still running
// Invariant: when pending job are running, all linked this._editors are started
// Second invariant is also maintained by link and unlink methods
const
startOperation
=
()
=>
{
this
.
_operations
++
;
if
(
this
.
_operations
==
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment