fn compute_syntax(&mut self, line: &str, state: State) -> State {
        let (mut parse_state, mut scope_state) = state.or_else(|| self.initial_state.clone()).unwrap();
        let ops = parse_state.parse_line(&line);

        let mut prev_cursor = 0;
        let repo = SCOPE_REPO.lock().unwrap();
        for (cursor, batch) in ops {
            if scope_state.len() > 0 {
                let scope_ident = self.stack_idents.get_value(scope_state.as_slice());
                let scope_ident = match scope_ident {
                    LookupResult::Existing(id) => id,
                    LookupResult::New(id) => {
                        let stack_strings = scope_state.as_slice().iter()
                            .map(|slice| repo.to_string(*slice))
                            .collect::<Vec<_>>();
                        self.new_scopes.push(stack_strings);
                        id
                    }
                };

                let start = self.offset - self.spans_start + prev_cursor;
                let end = start + (cursor - prev_cursor);
                if start != end {
                    let span = ScopeSpan::new(start, end, scope_ident);
                    self.spans.push(span);
                }
            }
            prev_cursor = cursor;
            scope_state.apply(&batch);
        }
        Some((parse_state, scope_state))
    }
// compute syntax for one line, also accumulating the style spans
compute syntax for one line, also accumulating the style spans
compute syntax for one line also accumulating the style spans
fn compute_syntax(&mut self, line: &str, state: State) -> State {
        let (mut parse_state, mut scope_state) = state.or_else(|| self.initial_state.clone()).unwrap();
        let ops = parse_state.parse_line(&line);
        let mut prev_cursor = 0;
        let repo = SCOPE_REPO.lock().unwrap();
        for (cursor, batch) in ops {
            if scope_state.len() > 0 {
                let scope_ident = self.stack_idents.get_value(scope_state.as_slice());
                let scope_ident = match scope_ident {
                    LookupResult::Existing(id) => id,
                    LookupResult::New(id) => {
                        let stack_strings = scope_state.as_slice().iter()
                            .map(|slice| repo.to_string(*slice))
                            .collect::<Vec<_>>();
                        self.new_scopes.push(stack_strings);
                        id
                    }
                };
                let start = self.offset - self.spans_start + prev_cursor;
                let end = start + (cursor - prev_cursor);
                if start != end {
                    let span = ScopeSpan::new(start, end, scope_ident);
                    self.spans.push(span);
                }
            }
            prev_cursor = cursor;
            scope_state.apply(&batch);
        }
        Some((parse_state, scope_state))
    }
fn compute_syntax ( & mut self , line : & str , state : State ) -> State { let ( mut parse_state , mut scope_state ) = state . or_else ( | | self . initial_state . clone ( ) ) . unwrap ( ) ; let ops = parse_state . parse_line ( & line ) ; let mut prev_cursor = 0 ; let repo = SCOPE_REPO . lock ( ) . unwrap ( ) ; for ( cursor , batch ) in ops { if scope_state . len ( ) > 0 { let scope_ident = self . stack_idents . get_value ( scope_state . as_slice ( ) ) ; let scope_ident = match scope_ident { LookupResult :: Existing ( id ) => id , LookupResult :: New ( id ) => { let stack_strings = scope_state . as_slice ( ) . iter ( ) . map ( | slice | repo . to_string ( * slice ) ) . collect :: < Vec < _ > > ( ) ; self . new_scopes . push ( stack_strings ) ; id } } ; let start = self . offset - self . spans_start + prev_cursor ; let end = start + ( cursor - prev_cursor ) ; if start != end { let span = ScopeSpan :: new ( start , end , scope_ident ) ; self . spans . push ( span ) ; } } prev_cursor = cursor ; scope_state . apply ( & batch ) ; } Some ( ( parse_state , scope_state ) ) }
compute syntax for one line, also accumulating the style spans
compute syntax for one line also accumulating the style spans
&mut self
line
&str
state
State